gpt4 book ai didi

java - 无法在项目上执行目标 org.apache.maven.plugins :maven-compiler-plugin:3. 3:compile (default-compile)

转载 作者:行者123 更新时间:2023-12-01 10:03:25 31 4
gpt4 key购买 nike

我是 Maven 的新手,我想将我的应用程序导入到 Maven。和以前一样,我想将我的 ejb 项目中的类引用到我的 war 项目中。我在类中没有错误,但是如果我在我的父项目上安装 maven,那么我的 war 项目会给我这个错误:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project SportunionWARModule: Compilation failure: Compilation failure:

[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/AdministratorenView.java:[6,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/AdministratorenView.java:[7,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/AdminEditor.java:[7,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/AdministratorenView.java:[41,30] cannot find symbol
[ERROR] symbol: class Admins
[ERROR] location: class com.sportunion.AdministratorenView
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/AdministratorenView.java:[42,30] cannot find symbol
[ERROR] symbol: class Log
[ERROR] location: class com.sportunion.AdministratorenView
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/CSVLoader.java:[8,30] package com.sportunion.project does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/CSVLoader.java:[9,36] package com.sportunion.project.utils does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/CSVLoader.java:[13,9] cannot find symbol
[ERROR] symbol: class UsersService
[ERROR] location: class com.sportunion.CSVLoader
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/BenutzerView.java:[9,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/BenutzerView.java:[53,30] cannot find symbol
[ERROR] symbol: class Users
[ERROR] location: class com.sportunion.BenutzerView
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/Ranking.java:[8,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/Ranking.java:[23,30] cannot find symbol
[ERROR] symbol: class Users
[ERROR] location: class com.sportunion.Ranking
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[8,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[9,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[10,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[35,25] cannot find symbol
[ERROR] symbol: class Admins
[ERROR] location: class com.sportunion.MyUI
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[36,29] cannot find symbol
[ERROR] symbol: class Users
[ERROR] location: class com.sportunion.MyUI
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[37,29] cannot find symbol
[ERROR] symbol: class Users
[ERROR] location: class com.sportunion.MyUI
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[38,29] cannot find symbol
[ERROR] symbol: class Log
[ERROR] location: class com.sportunion.MyUI
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LogView.java:[7,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LogView.java:[30,30] cannot find symbol
[ERROR] symbol: class Log
[ERROR] location: class com.sportunion.LogView
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[8,30] package com.sportunion.project does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[9,37] package com.sportunion.project.domain does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[10,30] package com.sportunion.project does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[11,36] package com.sportunion.project.utils does not exist
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/AdministratorenView.java:[101,32] cannot find symbol
[ERROR] symbol: class Admins
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/AdministratorenView.java:[101,68] cannot find symbol
[ERROR] symbol: class Admins
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/AdministratorenView.java:[101,80] cannot find symbol
[ERROR] symbol: class Admins
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/CSVLoader.java:[13,30] cannot find symbol
[ERROR] symbol: variable PTServiceLocator
[ERROR] location: class com.sportunion.CSVLoader
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/BenutzerView.java:[118,40] cannot find symbol
[ERROR] symbol: class Users
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/BenutzerView.java:[118,75] cannot find symbol
[ERROR] symbol: class Users
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/BenutzerView.java:[118,86] cannot find symbol
[ERROR] symbol: class Users
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[66,64] cannot find symbol
[ERROR] symbol: class Admins
[ERROR] location: class com.sportunion.MyUI
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[67,63] cannot find symbol
[ERROR] symbol: class Users
[ERROR] location: class com.sportunion.MyUI
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[68,65] cannot find symbol
[ERROR] symbol: class Users
[ERROR] location: class com.sportunion.MyUI
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/MyUI.java:[69,61] cannot find symbol
[ERROR] symbol: class Log
[ERROR] location: class com.sportunion.MyUI
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[41,13] cannot find symbol
[ERROR] symbol: class AdminsService
[ERROR] location: class com.sportunion.LoginView
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[41,36] cannot find symbol
[ERROR] symbol: variable PTServiceLocator
[ERROR] location: class com.sportunion.LoginView
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[42,13] cannot find symbol
[ERROR] symbol: class LogService
[ERROR] location: class com.sportunion.LoginView
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[42,30] cannot find symbol
[ERROR] symbol: variable PTServiceLocator
[ERROR] location: class com.sportunion.LoginView
[ERROR] /C:/jboss/workspace/Sportunion_Maven/SportunionParent/SportunionWARModule/src/main/java/com/sportunion/LoginView.java:[58,17] cannot find symbol
[ERROR] symbol: class Admins

现在有人知道我的错误是什么吗?

这是我的 war 项目的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>SportunionParent</artifactId>
<groupId>SportunionParent</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<groupId>SportunionParent</groupId>
<artifactId>SportunionWARModule</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>SportunionWARModule</name>

<properties>
<vaadin.version>7.6.4</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<jetty.plugin.version>9.2.3.v20140905</jetty.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
<repository>
<id>vaadin-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
</snapshots>
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-push</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<scope>provided</scope>
</dependency>
<!--
Needed when using the widgetset optimizer (custom ConnectorBundleLoaderFactory).

For widgetset compilation, vaadin-client-compiler is automatically added on the
compilation classpath by vaadin-maven-plugin so normally there is no need for an
explicit dependency.

<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<scope>provided</scope>
</dependency>-->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
</dependency>
<dependency>
<groupId> com.vaadin.addon </groupId>
<artifactId> jpacontainer </artifactId>
<version> 3.1.1 </version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>3.3</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude some unnecessary files generated by the GWT compiler. -->
<packagingExcludes>WEB-INF/classes/VAADIN/gwt-unitCache/**,
WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<configuration>
<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
<webappDirectory>${basedir}/target/classes/VAADIN/widgetsets</webappDirectory>
<draftCompile>false</draftCompile>
<compileReport>false</compileReport>
<style>OBF</style>
<strict>true</strict>
</configuration>
<executions>
<execution>
<goals>
<goal>update-theme</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
<!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
<!-- <goal>compile-theme</goal> -->
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6.1</version>
<!-- Clean up also any pre-compiled themes -->
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/VAADIN/themes</directory>
<includes>
<include>**/styles.css</include>
<include>**/styles.scss.cache</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>

<!-- The Jetty plugin allows us to easily test the development build by
running jetty:run on the command line. -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.plugin.version}</version>
<configuration>
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<!-- Vaadin pre-release repositories -->
<id>vaadin-prerelease</id>
<activation>
</activation>

<repositories>
<repository>
<id>vaadin-prereleases</id>
<url>http://maven.vaadin.com/vaadin-prereleases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>vaadin-prereleases</id>
<url>http://maven.vaadin.com/vaadin-prereleases</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>

这是我的 ejb 项目的 pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>SportunionParent</artifactId>
<groupId>SportunionParent</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<groupId>SportunionParent</groupId>
<artifactId>SportunionEJBModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ejb</packaging>

<name>SportunionEJBModule</name>

<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
<archive>
<manifest>
<addClasspath>true</addClasspath>

<!-- without this, the datetime stamp unique id's will be appended to classpath items -->
<!-- see: http://maven.apache.org/shared/maven-archiver/examples/classpath.html#Snapshot -->
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

这是我的耳朵项目中的一个:

<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>
<parent>
<groupId>SportunionParent</groupId>
<artifactId>SportunionParent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>SportunionEARModule</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>SportunionParent</groupId>
<artifactId>SportunionWARModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>SportunionParent</groupId>
<artifactId>SportunionEJBModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>ejb</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>

<configuration>
<hostname>127.0.0.1</hostname>
<port>9090</port>
<!-- <jbossHome>C:/tools/wildfly-8.0.0.Final</jbossHome> -->
</configuration>

</plugin>
</plugins>
</build>
<groupId>SportunionParent</groupId>
<version>0.0.1-SNAPSHOT</version>
</project>

如果有人能帮助我,我会很高兴...感谢您的建议!

最佳答案

正如您所提到的,缺少的元素存在于您的 EJB 模块中。

因此,您需要从 EAR 中删除作为依赖项的 EJB 模块,并将其添加到 WAR 模块中。在 WAR 的 pom.xml 文件中,添加以下内容:

<dependencies>
(...)

<dependency>
<groupId>SportunionParent</groupId>
<artifactId>SportunionEJBModule</artifactId>
<version>${project.version}</version>
</dependency>

(...)
</dependencies>

此外,由于 EJB 模块现在是您的 WAR 的依赖项,因此我相信您无需拥有 EAR。 Maven 会将您的 EJB 模块放置在 WAR 的 WEB-INF/lib 上。

关于java - 无法在项目上执行目标 org.apache.maven.plugins :maven-compiler-plugin:3. 3:compile (default-compile),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36633726/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com