eclipse创建maven工程编译的几个报错

本文介绍了在Eclipse中创建Maven工程时遇到的三个常见编译问题及解决方法:1. 调整JDK配置;2. 解决插件版本冲突,创建并配置lifecycle-mapping-metadata.xml文件;3. 处理TypeNotPresentException,升级JDK到1.7。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题1.右击项目  run as 选第二个  maven and build ....

报错:

解决方式:

修改一下jdk里面的配置


问题2:

CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: TypeNotPresentException: Type org.apache.maven.plugin.compiler.TestCompilerMojo not present: UnsupportedClassVersionError: org/apache/maven/plugin/compiler/TestCompilerMojo : Unsupported major.minor version 51.0

CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: TypeNotPresentException: Type org.apache.maven.plugin.compiler.CompilerMojo not present: UnsupportedClassVersionError: org/apache/maven/plugin/compiler/CompilerMojo : Unsupported major.minor version 51.0

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (execution: default-compile, phase: compile)

原因好像是因为插件版本冲突导致的,具体因为什么也不知道,百度之后找到解决方案:

1.进入Window—>Preferences—>Maven配置,进入Lifecycle Mapping设置项、

找到这个路径的这个文件,到工程的目录下发现没有这个文件,创建一个这个文件lifecycle-mapping-metadata.xml  内容如下:因为我的报错是少了testCompile和compile所以配置里面只加了这个两个

1.进入Window—>Preferences—>Maven配置,进入Lifecycle Mapping设置项 

找到这个路径的这个文件,到工程的目录下发现没有这个文件,创建一个这个文件lifecycle-mapping-metadata.xml  内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
    <pluginExecutions>
        <pluginExecution>
            <pluginExecutionFilter>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <goals>
                    <goal>testCompile</goal>
                    <goal>compile</goal>
                </goals>
                <versionRange>[1.4,)</versionRange>
            </pluginExecutionFilter>
            <action>
                <ignore />
            </action>
        </pluginExecution>
    </pluginExecutions>
</lifecycleMappingMetadata>

2.还是进入Window—>Preferences—>Maven配置,进入Lifecycle Mapping设置项
点击:Reload workspace......


3.并且设置 :

如果没有上图选项,需要先重启一下eclipse然后右击项目,maven--->update project....

4.重启eclipse  报错就消失了


问题3.java.lang.TypeNotPresentException: Type org.apache.maven.plugin.compiler.CompilerMojo not present

由于JDK版本为1.6  修改成1,7  并且导入1.7的JRE就好了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值