eclipse創建maven工程編譯的幾個報錯

問題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就好了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章