[Maven] Pom.xml error: Cannot detect Web Project version.

The newly created maven project reports the following error:

1 Cannot detect Web Project version. Please specify version of Web Project through <version> configuration property of war plugin. Eg: <plugin> <artifactId>maven-
 2   war-plugin</artifactId> <configuration> <version> 3.0 </ version> </configuration> </plugin>

Just add the following code in the pom.xml file:

1   < build > 
2        < plugins > 
3            < plugin > 
4                < artifactId > maven-war-plugin </ artifactId > 
5                < configuration > 
6                    < version > 3.0 </ version > 
7                </ configuration > 
8            </ plugin > 
9        < / plugins > 
10    </ build >

The following situations may also occur:

After adding the following code to the pom.xml file, the error is not eliminated, and the corresponding place in the .setting folder has been set, then

Copy the pom.xml file in a good maven project and use it to replace the pom.xml file.

For example: the complete pom.xml file:

< project xmlns ="http://maven.apache.org/POM/4.0.0" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation ="http:/ /maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > 
  < modelVersion > 4.0.0 </ modelVersion > 
  < groupId > com.agen. per </ groupId > 
  < artifactId > performance </ artifactId > 
  < version > 0.0.1-SNAPSHOT </ version >
  < packaging> war </ packaging > 
  < build > 
      < plugins > 
          < plugin > 
              < artifactId > maven-war-plugin </ artifactId > 
              < configuration > 
                  < version > 3.0 </ version > 
              </ configuration > 
          </ plugin > 
      </ plugins > 
  </ build >
  
      < properties > 
        < project .build.sourceEncoding > UTF-8 </ project.build.sourceEncoding > 
        < spring .version > 4.1.4.RELEASE </ spring.version > 
        < hibernate .version > 4.3.8.Final </ hibernate .version > 
    </ properties >
    
  < dependencies > 
      <!-- https://mvnrepository.com/artifact/javax.persistence/persistence-api --> 
    < dependency > 
        < groupId > javax.persistence </ groupId > 
        < artifactId > persistence-api </ artifactId > 
        < version > 1.0 </ version > 
    </ dependency > 
      <!-- Encryption operation --> 
        < dependency > 
            < groupId > commons-codec </ groupId> 
            < artifactId > commons-codec </ artifactId > 
            < version > 1.10 </ version > 
        </ dependency >
          
          <!-- https://mvnrepository.com/artifact/dom4j/dom4j --> 
        < dependency > 
            < groupId > dom4j </ groupId > 
            < artifactId > dom4j </ artifactId > 
            < version > 1.6.1 </ version > 
        < / dependency >

          
      <!-- WeChat Development Kit -->
        
        <!-- https://mvnrepository.com/artifact/com.github.binarywang/weixin-java-common --> 
        < dependency > 
            < groupId > com.github.binarywang </ groupId > 
            < artifactId > weixin-java- common </ artifactId > 
            < version > 2.2.0 </ version > 
        </ dependency > 
        <!-- https://mvnrepository.com/artifact/com.github.binarywang/weixin-java-mp --> 
        < dependency > 
            < groupId > com.github.binarywang</ groupId > 
            < artifactId > weixin-java-mp </ artifactId > 
            < version > 2.2.0 </ version > 
        </ dependency >
        
        <!-- https://mvnrepository.com/artifact/com.github.abj351r7/wechat-java-sdk --> 
        < dependency > 
            < groupId > com.github.abj351r7 </ groupId > 
            < artifactId > wechat-java- sdk </ artifactId > 
            < version > 1.0.1 </ version > 
        </ dependency >
        
        <!-- junit --> 
        < dependency > 
            < groupId > junit </ groupId > 
            < artifactId > junit </ artifactId > 
            < version > 4.12 </ version > 
            < scope > test </ scope > 
        </ dependency >

        <!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper --> 
        < dependency > 
            < groupId > com.github.pagehelper </ groupId > 
            < artifactId > pagehelper </ artifactId > 
            < version > 4.1.4 </ version > 
        </ dependency >
        
        <!-- spring --> 
        < dependency > 
            < groupId > org.springframework </ groupId > 
            < artifactId > spring-core </ artifactId > 
            < version > ${spring.version} </ version > 
        </ dependency >

        < dependency > 
            < groupId > org.springframework </ groupId > 
            < artifactId > spring-beans </ artifactId > 
            < version > ${spring.version} </ version > 
        </ dependency >

        < dependency > 
            < groupId > org.springframework </ groupId > 
            < artifactId > spring-context </ artifactId > 
            < version > ${spring.version} </ version > 
        </ dependency >

        < dependency > 
            < groupId > org.springframework </ groupId > 
            < artifactId > spring-tx </ artifactId > 
            < version > ${spring.version} </ version > 
        </ dependency >

        < dependency > 
            < groupId > org.springframework </ groupId > 
            < artifactId > spring-web </ artifactId > 
            < version > ${spring.version} </ version > 
        </ dependency >

        < dependency > 
            < groupId > org.springframework </ groupId > 
            < artifactId > spring-test </ artifactId > 
            < version > ${spring.version} </ version > 
            < scope > test </ scope > 
        </ dependency >

        <!-- Use SpringMVC to configure --> 
        < dependency > 
            < groupId > org.springframework </ groupId > 
            < artifactId > spring-webmvc </ artifactId > 
            < version > ${spring.version} </ version > 
        </ dependency > 
        <!-- spring cglib proxy --> 
        < dependency > 
            < groupId > cglib </ groupId > 
            < artifactId >cglib</ artifactId > 
            < version > 2.2.2 </ version > 
        </ dependency > 
        <!--When relational database integration requires configuration such as hibernate jpa, etc .--> 
        < dependency > 
            < groupId > org.springframework </ groupId > 
            < artifactId > spring-orm </ artifactId > 
            < version > ${spring.version} </ version > 
        </ dependency >

        <!-- hibernate --> 
        < dependency > 
            < groupId > org.hibernate </ groupId > 
            < artifactId > hibernate-core </ artifactId > 
            < version > ${hibernate.version} </ version > 
        </ dependency >

        < dependency > 
            < groupId > org.hibernate </ groupId > 
            < artifactId > hibernate-ehcache </ artifactId > 
            < version > ${hibernate.version} </ version > 
        </ dependency >

        <!-- Secondary cache ehcache --> 
        < dependency > 
            < groupId > net.sf.ehcache </ groupId > 
            < artifactId > ehcache </ artifactId > 
            < version > 2.9.0 </ version > 
        </ dependency >

        <!-- log4j --> 
        < dependency > 
            < groupId > log4j </ groupId > 
            < artifactId > log4j </ artifactId > 
            < version > 1.2.17 </ version > 
        </ dependency >

        <!-- mysql connection --> 
        < dependency > 
            < groupId > mysql </ groupId > 
            < artifactId > mysql-connector-java </ artifactId > 
            < version > 5.1.34 </ version > 
        </ dependency >

        <!-- c3p0 data source --> 
        < dependency > 
            < groupId > com.mchange </ groupId > 
            < artifactId > c3p0 </ artifactId > 
            < version > 0.9.5-pre10 </ version > 
        </ dependency >

        <!-- json -->

        <!-- No. 1 --> 
        < dependency > 
            < groupId > com.fasterxml.jackson.core </ groupId > 
            < artifactId > jackson-core </ artifactId > 
            < version > 2.8.1 </ version > 
        </ dependency > 
        <!-- No. 2 --> 
        < dependency > 
            < groupId > com.fasterxml.jackson.core </ groupId > 
            < artifactId >jackson-annotations</ artifactId > 
            < version > 2.8.1 </ version > 
        </ dependency >

        <!-- No. 3 --> 
        < dependency > 
            < groupId > com.fasterxml.jackson.core </ groupId > 
            < artifactId > jackson-databind </ artifactId > 
            < version > 2.8.1 </ version > 
            < exclusions > 
                < exclusion > 
                    < artifactId > jackson-core </ artifactId > 
                    < groupId > com.fasterxml.jackson.core </ groupId >
                </ exclusion > 
                < exclusion > 
                    < artifactId > jackson-annotations </ artifactId > 
                    < groupId > com.fasterxml.jackson.core </ groupId > 
                </ exclusion > 
            </ exclusions > 
        </ dependency >

        <!-- No. 4 --> 
        < dependency > 
            < groupId > com.google.code.gson </ groupId > 
            < artifactId > gson </ artifactId > 
            < version > 2.7 </ version > 
        </ dependency > 
        <!-- No. 5 --> 
        < dependency > 
            < groupId > net.sf.json-lib </ groupId > 
            < artifactId > json-lib </ artifactId> 
            < version > 2.4 </ version > 
            < classifier > jdk15 </ classifier > 
        </ dependency > 
        <!-- No. 5 json-lib also needs the following dependency packages --> 
        < dependency > 
            < groupId > commons-lang </ groupId > 
            < artifactId > commons-lang </ artifactId > 
            < version > 2.5 </ version > 
        </ dependency >
        <dependency > 
            < groupId > commons-beanutils </ groupId > 
            < artifactId > commons-beanutils </ artifactId > 
            < version > 1.9.2 </ version > 
        </ dependency > 
        < dependency > 
            < groupId > commons-collections </ groupId > 
            < artifactId > commons-collections </ artifactId > 
            < version >3.2.1 </version > 
        </ dependency > 
        < dependency > 
            < groupId > commons-logging </ groupId > 
            < artifactId > commons-logging </ artifactId > 
            < version > 1.2 </ version > 
        </ dependency >
        
        <!-- aop --> 
        < dependency > 
            < groupId > org.aspectj </ groupId > 
            < artifactId > aspectjweaver </ artifactId > 
            < version > 1.8.4 </ version > 
        </ dependency >

        <!-- servlet --> 
        < dependency > 
            < groupId > javax.servlet </ groupId > 
            < artifactId > servlet-api </ artifactId > 
            < version > 3.0-alpha-1 </ version > 
            < scope > provided </ scope > 
        </ dependency >

        < dependency > 
            < groupId > javax.servlet </ groupId > 
            < artifactId > jstl </ artifactId > 
            < version > 1.2 </ version > 
        </ dependency > 
        <!-- Merge operation of guava collection -->         
        < dependency > 
            < groupId > com.google.guava </ groupId > 
            < artifactId > guava </ artifactId > 
            <version> 19.0 </ version > 
        </ dependency > 
        < dependency > 
            < groupId > com.google.guava </ groupId > 
            < artifactId > guava-collections </ artifactId > 
            < version > r03 </ version > 
        </ dependency >
        
        <!-- File upload --> 
        < dependency > 
            < groupId > commons-fileupload </ groupId > 
            < artifactId > commons-fileupload </ artifactId > 
            < version > 1.3.1 </ version > 
        </ dependency >

  </ dependencies > 
</ project >


Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *