1. 程式人生 > >解決maven web項目Cannot detect Web Project version. Please specify version of Web Project through...的錯誤

解決maven web項目Cannot detect Web Project version. Please specify version of Web Project through...的錯誤

version 錯誤 web http conf mpi int war targe

前面已經聊了創建maven web工程,但是問題來了,創建maven web工程之後會出現如下的錯誤,在pom.xml文件頭部 有以下的錯誤

[plain] view plain copy print?
  1. Cannot detect Web Project version. Please specify version of Web Project through <version> configuration property of war plugin. E.g.: <plugin> <artifactId>maven-
  2. war-plugin</artifactId> <configuration> <version>3.0</version> </configuration> </plugin>


解決方法如下:

在pom.xml文件中加入:

[html] view plain copy print?
  1. <build>
  2. <plugins>
  3. <plugin>
  4. <artifactId>maven-compiler-plugin</artifactId>
  5. <configuration>
  6. <source>1.7</source>
  7. <target>1.7</target>
  8. </configuration>
  9. </plugin>
  10. <plugin>
  11. <artifactId>maven-war-plugin</artifactId>
  12. <version>2.4</version>
  13. <configuration>
  14. <version>3.0</version>
  15. </configuration>
  16. </plugin>
  17. </plugins>
  18. <finalName>webserver</finalName>
  19. </build>

那是因為項目未指定maven war編譯插件的錯誤

最後 maven - update project

解決maven web項目Cannot detect Web Project version. Please specify version of Web Project through...的錯誤