Generated target files after build doesn't contain all the compiled classes that must have been there

你。 提交于 2019-12-05 21:19:31

I found that the issue was due to some of the uncompilable classes inside the source packages because of that none of classes were being copied to the /target/classes/ folder. On removing the uncompilable source code I found it to be working fine.

maven does not place generated contents in src/main/webapp/WEB-INF/classes folder.

By default (and from the pom snippet above), it places the compiled classes in target/classes folder. In case of a war project, maven war plugin copies the classes to WEB-INF/classes folder within the webapp.

So, in your case, check the following folders:

  • C:\dev\ABCApp\target\classes
  • C:\dev\ABCApp\target\ABCApp\WEB-INF\classes

This also occurs with certain versions of the maven-compiler-plugin

The following fix resolved the issue for me and maven now correctly reports compiler errors. With the commented version below, maven would build successfully despite uncompilable code.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.0</version>
    <!--This version will happily build successfully when the code fails to compile-->
    <!--<version>3.1</version>-->
</plugin>

If package not creating in classes folder while code building maven project with spring boot application. This also occurs with certain versions of the maven-compiler-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.0</version>
    <!--This version will happily build successfully when the code fails to compile-->
    <!--<version>3.1</version>-->
          <configuration>
                <!--<skipMain>true</skipMain>-->
                <skip>true</skip>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
</plugin>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!