How can I build WAR with Maven in Eclipse?

后端 未结 3 1864
南笙
南笙 2020-12-14 10:35

I have project that I\'m now starting as Maven project, but for some reason it is not working. Here is my pom.xml:



        
3条回答
  •  粉色の甜心
    2020-12-14 10:59

    Actually, your POM looks a bit weird:

    • it is missing the right packaging for a webapp project.
    • the maven war plugin configuration doesn't look right, you just don't need the extra stuff you added.

    Here is what a minimal pom looks like:

    
      4.0.0
      com.mycompany.app
      my-webapp
      war
      1.0-SNAPSHOT
      
        
          junit
          junit
          3.8.1
          test
        
      
      
        my-webapp
      
    
    

    So either modify it and update the project configuration (right-click on your project then Maven > Update Project Configuration).

    Or just start over and create your project using the maven-archetype-webapp. You can do this from Eclipse: New > Project... > Maven Project, then select the maven-archetype-webapp in the wizzard and follow the seps.

    Or from the command line:

    mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
    

提交回复
热议问题