Java – Maven compilation does not create class files

I have a 3-module Maven project with the parent POM When I run Maven clean compile test from the parent process It failed in the test phase and provided a large number of compilation errors for my local class, saying "symbol not found"

If I use the "make project" button before running Maven test, I find that I use IntelliJ IDE, and then Maven test work!

Edit: now I find that probelem is compiled by Maven and will not create class files in the target folder. For some reason, this is my Maven compiler plug-in configuration in the parent POM file:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>

                <source>1.6</source>
                <target>1.6</target>
                <excludes>
                    <exclude>**/*.*</exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>

</build>

Any ideas?

Solution

Maven doesn't care about the missing symbols in the packaging phase; Missing symbols are reported only at compile time (= when Maven runs the java compiler)

To find out why symbols cannot be found, you need to check for one of the errors Look at the folder target and check for missing classes (in the correct location)

MVN clean deletes this folder, but MVN compile should put the new files there

If you don't see anything obvious, save a list of all files somewhere in the destination folder Then build the project in idea Create a list of all files again

Sort the two lists and compare them This may let you know what's wrong My guess is that you configured Maven in a strange way

Edit configuration

<excludes>
    <exclude>**/*.*</exclude>
</excludes>

Tell Maven to "ignore all source files", which is equivalent to "do nothing" Delete it and try again

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>