构建后生成的目标文件不包含所有必须存在的已编译类

发布于 2024-12-08 10:59:00 字数 20855 浏览 0 评论 0原文

在构建项目时,控制台显示源包已编译(px10 包内的源包),

但是如果我看到生成的目标文件,则源包中没有任何类。

  1. 尝试过干净& build 多次,但无助于
  2. .../var/cache/ 中清除 netbeans 缓存。

这是构建 Web 应用程序时生成的日志

------------------------------------------------------------------------
Building ABCApp Java EE 6 Webapp 1.0
------------------------------------------------------------------------

[antrun:run]
Executing tasks
Executed tasks

[resources:resources]
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
Copying 13 resources

[compiler:compile]
File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
Compiling 81 source files to C:\dev\ABCApp\target\classes
px10/BusinessLayer/LOBERs/connect.java:[248,38] ';' expected
px10/BusinessLayer/User/User_2.java:[127,52] '.class' expected

[resources:testResources]
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
Copying 1 resource

[compiler:testCompile]
Nothing to compile - all classes are up to date

[surefire:test]
Surefire report directory: C:\dev\ABCApp\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0


[war:war]
Packaging webapp
Assembling webapp [ABCApp] in [C:\dev\ABCApp\target\ABCApp]
Processing war project
Copying webapp resources [C:\dev\ABCApp\src\main\webapp]
Webapp assembled in [1841 msecs]
Building war: C:\dev\ABCApp\target\ABCApp.war
Warning: selected war files include a WEB-INF/web.xml which will be ignored 
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')

[install:install]
Installing C:\dev\ABCApp\target\ABCApp.war to C:\dev\mavenRepository\w93\ABCApp\1.0\ABCApp-1.0.war
Installing C:\dev\ABCApp\pom.xml to C:\dev\mavenRepository\w93\ABCApp\1.0\ABCApp-1.0.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 9.053s
Finished at: Tue Oct 04 11:49:46 IST 2011
Final Memory: 6M/15M
------------------------------------------------------------------------

此问题似乎是从我已经从我自己创建的 web-inf 文件夹中删除了一个名为 classes 的文件夹。

这是该项目的有效 POM:

<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>w93</groupId>
  <artifactId>ABCApp</artifactId>
  <version>1.0</version>
  <packaging>war</packaging>
  <name>ABCApp Java EE 6 Webapp</name>
  <url>http://maven.apache.org</url>
  <properties>
    <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-api</artifactId>
      <version>2.1.3_01</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-impl</artifactId>
      <version>2.1.3_01</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-web-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>0.9.30</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.primefaces</groupId>
      <artifactId>primefaces</artifactId>
      <version>3.0.M3</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>2.4.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.2.2</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <id>java.net2</id>
      <name>Repository hosting the jee6 artifacts</name>
      <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
      <id>jsf20</id>
      <name>Repository for library Library[jsf20]</name>
      <url>http://download.java.net/maven/2/</url>
    </repository>
    <repository>
      <id>prime-repo</id>
      <name>PrimeFaces Maven Repository</name>
      <url>http://repository.primefaces.org</url>
    </repository>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>http://repo1.maven.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>c:\dev\ABCApp\src\main\java</sourceDirectory>
    <scriptSourceDirectory>c:\dev\ABCApp\src\main\scripts</scriptSourceDirectory>
    <testSourceDirectory>c:\dev\ABCApp\src\test\java</testSourceDirectory>
    <outputDirectory>c:\dev\ABCApp\target\classes</outputDirectory>
    <testOutputDirectory>c:\dev\ABCApp\target\test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>c:\dev\ABCApp\src\main\resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>c:\dev\ABCApp\src\test\resources</directory>
      </testResource>
    </testResources>
    <directory>c:\dev\ABCApp\target</directory>
    <finalName>ABCApp</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <executions>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <compilerArguments>
                <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_23\jre\classes</bootclasspath>
              </compilerArguments>
              <source>1.6</source>
              <target>1.6</target>
              <failOnError>false</failOnError>
            </configuration>
          </execution>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <compilerArguments>
                <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_23\jre\classes</bootclasspath>
              </compilerArguments>
              <source>1.6</source>
              <target>1.6</target>
              <failOnError>false</failOnError>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-endorsed-api</artifactId>
            <version>6.0</version>
            <scope>compile</scope>
          </dependency>
        </dependencies>
        <configuration>
          <compilerArguments>
            <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_23\jre\classes</bootclasspath>
          </compilerArguments>
          <source>1.6</source>
          <target>1.6</target>
          <failOnError>false</failOnError>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <executions>
          <execution>
            <id>default-war</id>
            <phase>package</phase>
            <goals>
              <goal>war</goal>
            </goals>
            <configuration>
              <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <id>compile-protoc</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <mkdir dir="src/main/resources/protocolBuffers/compiled" />
                <path id="proto.path">
                  <fileset dir="src/main/proto">
                    <include name="**/*.proto" />
                  </fileset>
                </path>
                <pathconvert pathsep=" " property="proto.files" refid="proto.path" />
                <exec executable="src/main/resources/protocolBuffers/compiler/protoc" failonerror="true">
                  <arg value="--java_out=src/main/resources/" />
                  <arg value="-Ic:\dev\ABCApp/" />
                  <arg line="${proto.files}" />
                </exec>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.4.1</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.7.2</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>2.0.1</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>c:\dev\ABCApp\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>c:\dev\ABCApp\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>c:\dev\ABCApp\target\site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>c:\dev\ABCApp\target\site</outputDirectory>
  </reporting>
  <profiles>
    <profile>
      <id>endorsed</id>
      <activation>
        <property>
          <name>sun.boot.class.path</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <dependencies>
              <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-endorsed-api</artifactId>
                <version>6.0</version>
              </dependency>
            </dependencies>
            <configuration>
              <compilerArguments>
                <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_23\jre\classes</bootclasspath>
              </compilerArguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

While building the project, the console shows that the source packages were compiled(the one inside px10 package)

However if I see the target files generated, none of the classes are there from source package.

  1. tried clean & build several times but doesnt help
  2. cleared the netbeans cache from .../var/cache/

Here is the log generated while building the web app

------------------------------------------------------------------------
Building ABCApp Java EE 6 Webapp 1.0
------------------------------------------------------------------------

[antrun:run]
Executing tasks
Executed tasks

[resources:resources]
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
Copying 13 resources

[compiler:compile]
File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
Compiling 81 source files to C:\dev\ABCApp\target\classes
px10/BusinessLayer/LOBERs/connect.java:[248,38] ';' expected
px10/BusinessLayer/User/User_2.java:[127,52] '.class' expected

[resources:testResources]
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
Copying 1 resource

[compiler:testCompile]
Nothing to compile - all classes are up to date

[surefire:test]
Surefire report directory: C:\dev\ABCApp\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0


[war:war]
Packaging webapp
Assembling webapp [ABCApp] in [C:\dev\ABCApp\target\ABCApp]
Processing war project
Copying webapp resources [C:\dev\ABCApp\src\main\webapp]
Webapp assembled in [1841 msecs]
Building war: C:\dev\ABCApp\target\ABCApp.war
Warning: selected war files include a WEB-INF/web.xml which will be ignored 
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')

[install:install]
Installing C:\dev\ABCApp\target\ABCApp.war to C:\dev\mavenRepository\w93\ABCApp\1.0\ABCApp-1.0.war
Installing C:\dev\ABCApp\pom.xml to C:\dev\mavenRepository\w93\ABCApp\1.0\ABCApp-1.0.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 9.053s
Finished at: Tue Oct 04 11:49:46 IST 2011
Final Memory: 6M/15M
------------------------------------------------------------------------

This issue seems to be arising since I have deleted a folder named classes from inside web-inf folder which I myself had created.

Here is the effective POM for the project:

<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>w93</groupId>
  <artifactId>ABCApp</artifactId>
  <version>1.0</version>
  <packaging>war</packaging>
  <name>ABCApp Java EE 6 Webapp</name>
  <url>http://maven.apache.org</url>
  <properties>
    <netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-api</artifactId>
      <version>2.1.3_01</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.sun.faces</groupId>
      <artifactId>jsf-impl</artifactId>
      <version>2.1.3_01</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-web-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>0.9.30</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.primefaces</groupId>
      <artifactId>primefaces</artifactId>
      <version>3.0.M3</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>2.4.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.2.2</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <id>java.net2</id>
      <name>Repository hosting the jee6 artifacts</name>
      <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
      <id>jsf20</id>
      <name>Repository for library Library[jsf20]</name>
      <url>http://download.java.net/maven/2/</url>
    </repository>
    <repository>
      <id>prime-repo</id>
      <name>PrimeFaces Maven Repository</name>
      <url>http://repository.primefaces.org</url>
    </repository>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <url>http://repo1.maven.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>http://repo1.maven.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>c:\dev\ABCApp\src\main\java</sourceDirectory>
    <scriptSourceDirectory>c:\dev\ABCApp\src\main\scripts</scriptSourceDirectory>
    <testSourceDirectory>c:\dev\ABCApp\src\test\java</testSourceDirectory>
    <outputDirectory>c:\dev\ABCApp\target\classes</outputDirectory>
    <testOutputDirectory>c:\dev\ABCApp\target\test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>c:\dev\ABCApp\src\main\resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>c:\dev\ABCApp\src\test\resources</directory>
      </testResource>
    </testResources>
    <directory>c:\dev\ABCApp\target</directory>
    <finalName>ABCApp</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <executions>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <compilerArguments>
                <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_23\jre\classes</bootclasspath>
              </compilerArguments>
              <source>1.6</source>
              <target>1.6</target>
              <failOnError>false</failOnError>
            </configuration>
          </execution>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <compilerArguments>
                <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_23\jre\classes</bootclasspath>
              </compilerArguments>
              <source>1.6</source>
              <target>1.6</target>
              <failOnError>false</failOnError>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-endorsed-api</artifactId>
            <version>6.0</version>
            <scope>compile</scope>
          </dependency>
        </dependencies>
        <configuration>
          <compilerArguments>
            <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_23\jre\classes</bootclasspath>
          </compilerArguments>
          <source>1.6</source>
          <target>1.6</target>
          <failOnError>false</failOnError>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <executions>
          <execution>
            <id>default-war</id>
            <phase>package</phase>
            <goals>
              <goal>war</goal>
            </goals>
            <configuration>
              <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <id>compile-protoc</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <mkdir dir="src/main/resources/protocolBuffers/compiled" />
                <path id="proto.path">
                  <fileset dir="src/main/proto">
                    <include name="**/*.proto" />
                  </fileset>
                </path>
                <pathconvert pathsep=" " property="proto.files" refid="proto.path" />
                <exec executable="src/main/resources/protocolBuffers/compiler/protoc" failonerror="true">
                  <arg value="--java_out=src/main/resources/" />
                  <arg value="-Ic:\dev\ABCApp/" />
                  <arg line="${proto.files}" />
                </exec>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.4.1</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.7.2</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>2.0.1</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>c:\dev\ABCApp\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>c:\dev\ABCApp\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>c:\dev\ABCApp\target\site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>c:\dev\ABCApp\target\site</outputDirectory>
  </reporting>
  <profiles>
    <profile>
      <id>endorsed</id>
      <activation>
        <property>
          <name>sun.boot.class.path</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <dependencies>
              <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-endorsed-api</artifactId>
                <version>6.0</version>
              </dependency>
            </dependencies>
            <configuration>
              <compilerArguments>
                <bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_23\jre\lib\modules\jdk.boot.jar;C:\Program Files\Java\jdk1.6.0_23\jre\classes</bootclasspath>
              </compilerArguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

青春如此纠结 2024-12-15 10:59:00

我发现问题是由于源包中的一些无法编译的类造成的,因为没有任何类被复制到 /target/classes/ 文件夹中。在删除无法编译的源代码时,我发现它工作正常。

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.

绿光 2024-12-15 10:59:00

maven 不会将生成的内容放在 src/main/webapp/WEB-INF/classes 文件夹中。

默认情况下(以及上面的 pom 片段),它将编译后的类放置在 target/classes 文件夹中。如果是 war 项目,maven war 插件 将类复制到 web 应用程序内的 WEB-INF/classes 文件夹中。

因此,根据您的情况,请检查以下文件夹:

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

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
风情万种。 2024-12-15 10:59:00

某些版本的 maven-compiler-plugin 也会出现这种情况。

以下修复解决了我的问题,maven 现在可以正确报告编译器错误。
使用下面的注释版本,尽管存在无法编译的代码,maven 仍会成功构建。

<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>

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>
赴月观长安 2024-12-15 10:59:00

如果在使用 Spring Boot 应用程序构建 Maven 项目的代码时未在类文件夹中创建包。
某些版本的 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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文