我有父Maven模块:
<?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.test</groupId>
<artifactId>atata</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>core</module>
<module>runner</module>
</modules>
</project>
Run Code Online (Sandbox Code Playgroud)
它有两个孩子。
<parent>
<artifactId>atata</artifactId>
<groupId>com.test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>runner</artifactId>
Run Code Online (Sandbox Code Playgroud)
和
<parent>
<artifactId>atata</artifactId>
<groupId>com.test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>core</artifactId>
Run Code Online (Sandbox Code Playgroud)
在Core我有一个代码:
public class A {
public void fun() {
System.out.println("Hello!");
}
}
Run Code Online (Sandbox Code Playgroud)
在Runner模块中,我使用A类:
public class Runner {
public static void main(String[] args) {
new A().fun();
}
}
Run Code Online (Sandbox Code Playgroud)
但是现在我的跑步者没有上课A。是否可以使其可见?
Core在Runnerpom中创建依赖项:
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
请注意,依赖关系只能以一种方式发生,因此您不能依赖Runnerfrom Core,因为它会导致不允许的循环依赖关系。不过,从模块名称来看,您似乎有一个良好的开端。
| 归档时间: |
|
| 查看次数: |
638 次 |
| 最近记录: |