[英]Copy files from one target folder to another in multimodule maven project
[英]How to import artifact from one subproject into another in multimodule project?
同事,我的多模塊項目中有子項目utils
。 pom看起來像:
<?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">
<parent>
<artifactId>parent</artifactId>
<groupId>com.comp.kort</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>utils</artifactId>
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${project.build.sourceJdk}</source>
<target>${project.build.targetJdk}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
我運行命令mvn clean install
並在本地maven存儲庫中創建了utils-1.0-SNAPSHOT.jar
。
之后,我將下一個依賴項添加到另一個子項目的pom中
<dependency>
<groupId>com.comp.kort</groupId>
<artifactId>utils</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
但是,當我將import com.comp.kort
添加到第二個子項目的類中時,我收到Can't resolve symbol 'kort'
。
我應如何在第二個子項目中正確導入com.comp.kort?
我的第二個子項目上的mvn dependency:tree
顯示:
[INFO] com.comp.kort:kort-sp-integration:jar:1.0-SNAPSHOT
[INFO] +- org.springframework.batch:spring-batch-core:jar:3.0.7.RELEASE:compile
[INFO] | +- com.ibm.jbatch:com.ibm.jbatch-tck-spi:jar:1.0:compile
[INFO] | | \- javax.batch:javax.batch-api:jar:1.0:compile
[INFO] | +- com.thoughtworks.xstream:xstream:jar:1.4.7:compile
[INFO] | | +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | +- org.codehaus.jettison:jettison:jar:1.2:compile
[INFO] | +- org.springframework.batch:spring-batch-infrastructure:jar:3.0.7.RELEASE:compile
[INFO] | | \- org.springframework.retry:spring-retry:jar:1.1.0.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:4.0.5.RELEASE:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:4.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:4.0.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-expression:jar:4.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-core:jar:4.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:4.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.2.6.RELEASE:compile
[INFO] +- org.apache.commons:commons-dbcp2:jar:2.1.1:compile
[INFO] | +- org.apache.commons:commons-pool2:jar:2.4.2:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- commons-io:commons-io:jar:2.2:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- com.microsoft.sqlserver:sqljdbc4:jar:4.2:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- com.sun.mail:javax.mail:jar:1.5.5:compile
[INFO] | \- javax.activation:activation:jar:1.1:compile
[INFO] \- com.comp.kort:utils:jar:1.0-SNAPSHOT:compile
似乎<scope>provided</scope>
不正確,您可以將其刪除。
提供的就像編譯,但是表明您希望JDK或容器在運行時提供依賴項。 例如,在為Java Enterprise Edition構建Web應用程序時,您將對Servlet API和相關Java EE API的依賴關系設置為提供的范圍,因為Web容器提供了這些類。 該作用域僅在編譯和測試類路徑上可用,並且不可傳遞。
你可以在這里看到
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.