Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor

試著忘記壹切 提交于 2019-12-02 15:00:21

Perhaps a version of maven war plugin is being used, which does not work with Java 7? As per this issue (which describes a similar problem), 2.1.1 version of maven war plugin should work.

Include the following in your pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>
</plugin>

I had this problem when doing a mvn install. I resolved it by doing a mvn clean first, followed by a mvn install.

Using maven 2.1.1, JDK 1.7.0.45.

visu

It's confirmed: JDK7 with Maven 2.x will produce this error.

I am using Maven 2.2.1 and JDK7 and got this error. I changed the JDK to version 1.6 and it's working fine.

Instead of changing JDK versions and Maven versions, try this:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
    </configuration>
    <version>2.3.2</version>
</plugin>

Confirmed, I ran into the same issue with maven 3.0.2 and jdk 1.7.0_02. After running against jdk 1.6.0_30 it compiled just fine.

J S

I don't think the version was the problem. I solved deleting my target folder (because it contains webapp-cache.xml) and doing Maven install again.

Motilal Daravatu

if your using jdk 1.6 kindly add this plugin entry to your pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <compilerArgument>-Xlint:all</compilerArgument>
        <showWarnings>true</showWarnings>
        <showDeprecation>true</showDeprecation>
    </configuration>
</plugin>

This definitely seems to be related to incompatible plugin, library and language versions.

Two years, and two Java versions later, I had this same error while doing a sample project from an older book on Spring and Hibernate.

I was able to resolve the error by commenting out all of the version tags for the apache.maven.plugins and setting the Java version to 1.8. This let me know what was the latest and greatest version of the libraries, with the cost of some warnings from Maven about missing the version tags. If you care about the warnings, you can set the version tags to be latest version and the warnings from Maven should go away.

I executed mvn clean package and then just mvn package.

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-war-plugin</artifactId>
<!-- <version>2.1-beta-1</version> -->
</plugin>
<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-compiler-plugin</artifactId>
<!-- <version>2.1</version> -->
     <configuration>
          <source>1.8</source>
          <target>1.8</target>
     </configuration>
</plugin>

I had this problem with my eclipse Kepler. As soon as I moved to 4.4 (Luna) , all gone. Must be an issue with eclipse + maven embedded

I tried both JDK 1.7 and 1.8. No difference.

For me changing plugin version could not solve problme and changing JDK version is not in my control.

However running mvn clean before mvn tomcat6:deploy solved this problem.

vinay

Make sure to have the JDK version in your Build path and the version specified in the source tag match the same.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.1</version>
    <configuration>
     **<source>1.7</source>**
       <target>1.7</target>
       <debug>true</debug>
    </configuration>
</plugin> `

I had the build path pointing to jdk 1.7 and "1.6" in the source tag, when I corrected the version to 1.7 in source tag the issue got resolved.

Execute mnv clean and mvn package.

Try to delete all your cache. When i deleted target folder, it works fine.

(Target folder is where maven puts all compiled code)

I was getting the same error after i upgraded my java version from 8 to some 8.x, i fixed it by going to pom then 1. right click > maven > add plugin 2. type in org.apache.maven and then look for war plugin add it and save, then just clean and install. It should work.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!