Maven Compile Error

后端 未结 8 2028
南笙
南笙 2020-12-15 08:52

When I build and run my program in Netbeans, it works without a problem. But with same pom.xml file when I try \"mvn compile\" I get this error:

[ERROR] Fail         


        
8条回答
  •  庸人自扰
    2020-12-15 09:38

    Here is a slightly different way to fix the same error in Eclipse Indigo.

    • Open your (maven) project in Eclipse.
    • right click on pom.xml
    • select ...Maven...Add Plugin
    • Enter:

        - groupId: org.apache.maven.plugins
        - artifactId: maven-compiler-plugin
        - version: 2.3.2
      

    This will insert a new section in your pom.xml and open a window for editing.

    Then you can add the source and target xml elements as described above to select the correct JRE.

    The section looks like this in my project:

    
      
         
            org.apache.maven.plugins
            maven-compiler-plugin
            2.3.2
            
               1.6
               1.6
            
         
      
    
    

    Note the extra tags for "build" and "plugins" absent in some of the other posts.

    Once you save the file, Eclipse will notify you that your pom is out of synch with your project.

    You can then right click the project ...choose Maven..update project

    A key insight for me was that Maven will automatically re-set the build path in Eclipse. Which you can verify by Project...build path..configure build path...Libraries.

    So in essence this means you should not have to mess with directly configuring the build path in Eclipse if you are using a Maven project.

    HTH

提交回复
热议问题