以下是我的情况:
shared api
(jar),web app
(战争),desktop swing app
(jar)。后者2取决于共享api。eftracker
(root pom),eftracker-parent
,eftracker-shared
,eftracker-web
。 mvn package
上运行eftracker
所有作品都很完美 - 我按预期创建了eftracker-shared.jar
和eftracker-web.war
tomcat7-maven-plugin
来运行带有maven目标tomcat7:run
的网络应用,以测试在开发过程中所做的更改eftracker-shared
作为项目添加到eftracker-web
构建路径。我的目标:
我的问题:
mvn install
而不是尝试调用tomcat7:run
,则会导致错误:Failed to execute goal on project eftracker-web: Could not resolve dependencies for project com.skarpushin:eftracker-web:war:1.503.0: Could not find artifact com.skarpushin:eftracker-shared:jar:1.503.0 in central (https://repo.maven.apache.org/maven2)
mvn clean install
并查看最近的更改之前,每次更改项目时,我都必须tomcat7:run
共享项目(甚至是根模块)。问题是:
eftracker.pom
<?xml version="1.0"?>
<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>
<groupId>com.skarpushin</groupId>
<artifactId>eftracker</artifactId>
<version>1.503.0</version>
<packaging>pom</packaging>
<name>eftracker</name>
<modules>
<module>eftracker-parent</module>
<module>eftracker-shared</module>
<module>eftracker-web</module>
</modules>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
</project>
eftracker-父/ 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>
<groupId>com.skarpushin</groupId>
<version>1.503.0</version>
<artifactId>eftracker-parent</artifactId>
<packaging>pom</packaging>
<name>eftracker-parent</name>
<!-- ...some common properties, dependencies, build plugins... -->
</project>
eftracker幅/ 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">
<parent>
<groupId>com.skarpushin</groupId>
<artifactId>eftracker-parent</artifactId>
<version>1.503.0</version>
<relativePath>../eftracker-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>eftracker-web</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<port>8080</port>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>ROOT##${project.version}</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.skarpushin</groupId>
<artifactId>eftracker-shared</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ...other deps -->
</dependencies>
</project>
答案 0 :(得分:0)
尝试使用M2Eclipse https://www.eclipse.org/m2e/
M2Eclipse为Apache Maven提供了与IDE的紧密集成 具有以下功能:
- 从Eclipse中启动Maven构建
- 基于Maven的pom.xml的Eclipse构建路径的依赖关系管理
- 从Eclipse工作区解析Maven依赖项而不安装到本地Maven存储库
- 从远程Maven存储库自动下载所需的依赖项
- 用于创建新Maven项目,pom.xml以及在普通Java项目上启用Maven支持的向导
- 快速搜索Maven远程存储库中的依赖项
答案 1 :(得分:0)