我有一个eclipse java / jar项目,用于静态链接到其他jar文件。我将这个项目重新制作成了一个maven项目(清单1),所以我可以删除这些静态jar文件并让maven解决它们。 我还有另一个war web应用程序,我还转换了另一个项目MyWarProject,它曾经依赖MyJarProject到maven。并将MyJarProject添加为依赖项(清单2)。
这是我的jar项目的上半部分pom.xml
<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>MyJarProject</groupId>
<artifactId>MyJarProject</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>......
这是war项目的完整列表pom.xml,它依赖于jar文件
<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>MyWarProject</groupId>
<artifactId>MyWarProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>MyJarProject</groupId>
<artifactId>MyJarProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
第一个jar项目在maven clean install之后构建良好。但是war项目显示此错误消息。那些像ItemsDAO这样缺少的类应该从jar项目中解析出来。 并且实际上没有jar文件被复制到WEB-INF文件夹。请帮忙!
INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ MyWarProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ MyWarProject ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 41 source files to C:\Users\iaddou\workspace1\MyWarProject\target\classes
[INFO] Some input files use or override a deprecated API.
[INFO] Recompile with -Xlint:deprecation for details.
[INFO] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\utility\MegaItemProcessCodeType.java uses unchecked or unsafe operations.
[INFO] Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/utility/WebServicesLogger.java:[3,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\utility\WebServicesLogger.java:3: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/utility/WebServicesLogger.java:[15,32] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\utility\WebServicesLogger.java:15: package com.documentum.fc.client does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/utility/WebServicesLogger.java:[216,17] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\utility\WebServicesLogger.java:216: cannot find symbol
symbol : class IDfSession
location: class com.rd.test.MyWarProject.utility.WebServicesLogger
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemsImpl.java:[15,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemsImpl.java:15: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemsImpl.java:[16,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemsImpl.java:16: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemsImpl.java:[17,35] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemsImpl.java:17: package com.rd.test.common.data does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemsImpl.java:[42,13] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemsImpl.java:42: cannot find symbol
symbol : class ItemsDAO
location: class com.rd.test.MyWarProject.MegaItemsImpl
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemVersionHistoryImpl.java:[11,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemVersionHistoryImpl.java:11: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemVersionHistoryImpl.java:[12,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemVersionHistoryImpl.java:12: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemVersionHistoryImpl.java:[13,35] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemVersionHistoryImpl.java:13: package com.rd.test.common.data does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemVersionHistoryImpl.java:[40,17] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemVersionHistoryImpl.java:40: cannot find symbol
symbol : class VersionHistoryDAO
location: class com.rd.test.MyWarProject.MegaItemVersionHistoryImpl
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemDetailImpl.java:[12,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemDetailImpl.java:12: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemDetailImpl.java:[13,30] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemDetailImpl.java:13: package com.rd.test.common does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemDetailImpl.java:[14,35] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemDetailImpl.java:14: package com.rd.test.common.data does not exist
[ERROR] /C:/Users/iaddou/workspace1/MyWarProject/src/com/rd/test/MyWarProject/MegaItemDetailImpl.java:[39,17] C:\Users\iaddou\workspace1\MyWarProject\src\com\rd\test\MyWarProject\MegaItemDetailImpl.java:39: cannot find symbol
symbol : class ItemDAO