定義依賴我有一個項目,我在兩種不同的方式試圖建設:的Maven:項目編譯沒有在pom.xml中
- 隨着
-Dmaven.repo.local
設置爲只爲構建創造了一個全新的目錄。 - 沒有
-Dmaven.repo.local
(那麼我想它默認爲~/.m2
我發現很奇怪,我的項目編譯就好了,當我不使用-Dmaven.repo.local
,即使一些依賴是不是在POM,日誌不顯示這些依賴下載或解決從本地回購(~/.m2
)。
如果我嘗試建立指定一個全新的本地資源庫,構建因爲javac是無法化解一些類失敗(意味着Maven和Java不知道這些依賴關係在哪裏)。
[ERROR] /home/jenkins1/slave_home/workspace/Build/2.x/Dev_Test/2-Mainline_Stream_official_Green_build_V2/workspace/com.mycompany.myproj.iaas.rest/src/main/java/com/mycompany/myproj/iaas/api/rest/MigrationUninstallModulesResource.java:[18,23] error: package javax.ws.rs.core does not exist
[ERROR] /home/jenkins1/slave_home/workspace/Build/2.x/Dev_Test/2-Mainline_Stream_official_Green_build_V2/workspace/com.mycompany.myproj.iaas.rest/src/main/java/com/mycompany/myproj/iaas/api/rest/MigrationUninstallModulesResource.java:[42,1] error: cannot find symbol
[ERROR] symbol: class Path
[ERROR] /home/jenkins1/slave_home/workspace/Build/2.x/Dev_Test/2-Mainline_Stream_official_Green_build_V2/workspace/com.mycompany.myproj.iaas.rest/src/main/java/com/mycompany/myproj/iaas/api/rest/assets/MigrationUninstallModulesAsset.java:[16,18] error: package javax.ws.rs does not exist
[ERROR] /home/jenkins1/slave_home/workspace/Build/2.x/Dev_Test/2-Mainline_Stream_official_Green_build_V2/workspace/com.mycompany.myproj.iaas.rest/src/main/java/com/mycompany/myproj/iaas/api/rest/assets/MigrationUninstallModulesAsset.java:[17,23] error: package javax.ws.rs.core does not exist
[ERROR] /home/jenkins1/slave_home/workspace/Build/2.x/Dev_Test/2-Mainline_Stream_official_Green_build_V2/workspace/com.mycompany.myproj.iaas.rest/src/main/java/com/mycompany/myproj/iaas/api/rest/assets/MigrationUninstallModulesAsset.java:[19,41] error: package org.apache.wink.common.annotations does not exist
[ERROR] /home/jenkins1/slave_home/workspace/Build/2.x/Dev_Test/2-Mainline_Stream_official_Green_build_V2/workspace/com.mycompany.myproj.iaas.rest/src/main/java/com/mycompany/myproj/iaas/api/rest/assets/MigrationUninstallModulesAsset.java:[23,1] error: cannot find symbol
[ERROR] symbol: class Asset
[ERROR] /home/jenkins1/slave_home/workspace/Build/2.x/Dev_Test/2-Mainline_Stream_official_Green_build_V2/workspace/com.mycompany.myproj.iaas.rest/src/main/java/com/mycompany/myproj/iaas/api/rest/assets/TeamAsset.java:[12,18] error: package javax.ws.rs does not exist
[ERROR] -> [Help 1]
正如你所看到的,構建沒有找到javax.ws.rs
,這是意料之中的,因爲依賴是不是在POM。我不明白的是當我壓制-Dmaven.local.repo
時,構建成功的原因。
的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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.myproj.iaas</groupId>
<artifactId>root</artifactId>
<version>2.1.0</version>
<relativePath>../com.mycompany.myproj.iaas</relativePath>
</parent>
<groupId>com.mycompany.myproj.iaas</groupId>
<artifactId>rest</artifactId>
<packaging>war</packaging>
<name>myproj myproj-RestAPI.war</name>
<url>http://www.mycompany.com</url>
<dependencies>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mycompany.myproj.iaas</groupId>
<artifactId>common</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.mycompany.myproj.iaas</groupId>
<artifactId>bpm</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.mycompany.myproj.iaas</groupId>
<artifactId>sql</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-server</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${version.logback}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-json-provider</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.wink</groupId>
<artifactId>wink-json4j</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ripe.commons</groupId>
<artifactId>commons-ip-math</artifactId>
<version>1.21.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc4</artifactId>
<version>10.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc_license_cu</artifactId>
<version>10.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Version>${project.version}.${buildLabel}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<parallel>methods</parallel>
<threadCount>10</threadCount>
</configuration>
<version>2.17</version>
</plugin>
</plugins>
</build>
<description>This component builds the myproj-RestAPI.war file.</description>
</project>
這是非常令人困惑 - 如果依賴沒有在POM定義,它是如何得到解決?
不清楚,是在POM宣佈這些事情傳遞依賴? – Tunaki
爲什麼不粘貼你的問題上的日誌? – thiagoh
@Tunaki POM中沒有聲明依賴關係。這是在問題描述:) – Phil