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

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

eclipse创建maven工程编译的几个报错_第1张图片

报错:

eclipse创建maven工程编译的几个报错_第2张图片

解决方式:

修改一下jdk里面的配置

eclipse创建maven工程编译的几个报错_第3张图片

问题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)

eclipse创建maven工程编译的几个报错_第4张图片

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

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

eclipse创建maven工程编译的几个报错_第5张图片

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

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

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



    
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    testCompile
                    compile
                
                [1.4,)
            
            
                
            
        
    

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

eclipse创建maven工程编译的几个报错_第6张图片


3.并且设置 :

eclipse创建maven工程编译的几个报错_第7张图片

如果没有上图选项,需要先重启一下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就好了

你可能感兴趣的:(eclipse创建maven工程编译的几个报错)