我是Maven的新手,我想将我的应用程序导入maven。 我想像以前一样,将我的ejb项目中的课程引用到我的战争项目中。 我在课堂上没有错误,但是如果我在我的父项目上安装maven,那么我的war-project会给我这个错误:
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
现在有人知道我的错吗?
这是我的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>
如果有人能帮助我,我会很高兴...感谢您的建议!
答案 0 :(得分:1)
正如您所提到的,EJB模块中存在缺少的元素。
因此,您需要删除您的EJB模块作为EAR的依赖项并将其添加到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 上。