spring - Spring Initializr 生成的 pom.xml 出错

标签 spring maven spring-boot kotlin pom.xml

我正在使用 Spring Tool Suite,我想用 Kotlin、Spring 和 Maven 制作一个 REST API,但是在通过 Spring Initializr 创建项目后我的 pom.xml 出现错误。我的“父”标签引发错误,但我猜问题来自 kotlin-maven-plugin。我不知道这个 pom.xml 有什么问题。如果有人可以帮我解决这个问题,我将不胜感激!

这是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>fr.asi</groupId>
<artifactId>api_kotlin_test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>api_kotlin_test</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <kotlin.version>1.2.51</kotlin.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-cache</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.module</groupId>
        <artifactId>jackson-module-kotlin</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib-jdk8</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-reflect</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <artifactId>kotlin-maven-plugin</artifactId>
            <groupId>org.jetbrains.kotlin</groupId>
            <configuration>
                <args>
                    <arg>-Xjsr305=strict</arg>
                </args>
                <compilerPlugins>
                    <plugin>spring</plugin>
                    <plugin>jpa</plugin>
                </compilerPlugins>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-allopen</artifactId>
                    <version>${kotlin.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-noarg</artifactId>
                    <version>${kotlin.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

我有这个错误:

Project configurator "org.jetbrains.kotlin.maven.projectConfigurator" required by plugin execution "org.jetbrains.kotlin:kotlin-maven-plugin:1.2.51:test-compile (execution: test-compile, phase: test-compile)" is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration.

最佳答案

我在 pom.xml 中添加了一个属性,如下所示:

<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>

添加此属性后,只需保存您的 pom.xml 并更新您的项目。该错误应得到解决。 下面是 pom.xml 的一个片段:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.8.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.in28minutes.learning.jpa</groupId>
    <artifactId>jpa-in-10-steps</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>jpa-in-10-steps</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
    </properties>

关于spring - Spring Initializr 生成的 pom.xml 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53341411/

相关文章:

java - Spring-Boot 中的多个数据库与 mariaDB

java - 对 CXF 服务器的 C/C++ SSL 请求

java - 如何使 Spring Security 应用程序在代理后面运行?

java - 无法使用服务名称连接到 Oracle 数据库

java - 将 Maven 项目作为依赖项添加到 Android Studio 应用程序

java - 在 SSL 中使用 Spring BOOT 进行 SOAP 身份验证

spring - 注入(inject)和资源以及 Autowiring 注释

java - hibernate : One Entitiy class for multiple purpose?

java - 当我的测试失败且 chrome 浏览器关闭之前(@After)时,如何对 chrome 浏览器进行屏幕截图

java - 如何通过Gateway/Api Gateway/Rest将外部服务连接到队列?