相关文章推荐
闯红灯的煎鸡蛋  ·  Kotlin ...·  2 周前    · 
拉风的椅子  ·  kotlin int 转 string ...·  2 周前    · 
留胡子的汤圆  ·  Day 8 ─用Kotlin ...·  2 周前    · 
完美的油条  ·  内存泄漏 - ...·  1 年前    · 
谦和的跑步鞋  ·  DateTimePicker 类 ...·  1 年前    · 
强健的硬币  ·  mybatis+springmvc+sqli ...·  1 年前    · 

在配置kotlin的MAVEN项目中,Eclipse出现以下错误:

Plugin execution not covered by lifecycle configuration: org.jetbrains.kotlin:kotlin-maven-plugin:1.2.41:compile (execution: compile, phase: compile)

解决办法如下,在POM配置文件的plugins标签上包装pluginManagement标签,最终的代码如下:

<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>pre-unit-tests</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${project.testresult.directory}/coverage/jacoco/jacoco.exec</destFile>
</configuration>
</execution>
<!-- Ensures that the code coverage report for unit tests is created after unit tests have been run -->
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.testresult.directory}/coverage/jacoco/jacoco.exec</dataFile>
<outputDirectory>${project.testresult.directory}/coverage/jacoco</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>

导入 kotlin项目

kotlin入门教程_spring

kotlin入门教程_spring_02

Error:Kotlin: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class org.springframework.http.HttpStatus, unresolved supertypes: java.lang.Enum
class org.springframework.data.jpa.repository.JpaRepository, unresolved supertypes: java.lang.Object
class org.springframework.data.repository.PagingAndSortingRepository, unresolved supertypes: java.lang.Object
class org.springframework.data.repository.CrudRepository, unresolved supertypes: java.lang.Object
class org.springframework.data.repository.Repository, unresolved supertypes: java.lang.Object
class org.springframework.data.repository.query.QueryByExampleExecutor, unresolved supertypes: java.lang.Object
class javax.persistence.GenerationType, unresolved supertypes: java.lang.Enum
class org.springframework.data.domain.Pageable, unresolved supertypes: java.lang.Object
class org.springframework.data.domain.Sort, unresolved supertypes: java.lang.Object, java.io.Serializable
class org.springframework.data.util.Streamable, unresolved supertypes: java.lang.Object, java.lang.Iterable
class org.springframework.data.domain.Example, unresolved supertypes: java.lang.Object
14:19 Compilation completed with 48 errors and 0 warnings in 7 s 344 ms

14:25 Maven 3.3.1+ requires JDK 1.7+. Please set appropriate JDK at
Settings | Build, Execution, Deployment | Build Tools | Maven | Runner | JRE

14:25 Error running 'mvn install': No JDK specified

14:25 Maven 3.3.1+ requires JDK 1.7+. Please set appropriate JDK at
Settings | Build, Execution, Deployment | Build Tools | Maven | Runner | JRE

14:25 Error running 'mvn install': No JDK specified

修改maven 设置

kotlin入门教程_java_03

kotlin入门教程_java_04

创建maven clean install 命令