我需要使用来自不同项目的基本代码。项目文件夹的布局如下:
cs4500-sinanspd-maxlever
|
------ 2
|
------ 3
所以2& 3是主文件夹下的子目录,它们是2个SEPARATE项目。我成功地将模块2链接到IntelliJ中的模块3。
我可以使用它。 IntelliJ查找源文件夹中的所有类
但是当我尝试编译项目3时,我得到以下 ERROR :
java: package schema does not exist
现在我做了一些研究,但我找到的解决方案不起作用:
Maven compile: package does not exist
Maven: best way of linking custom external JAR to my project?
我不能使用mvn install:install-file,因为这是一个模块而不是jar
项目3的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">
<modelVersion>4.0.0</modelVersion>
<groupId>3</groupId>
<artifactId>3</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>2</groupId>
<artifactId>2</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
并且iml文件显示成功设置的库路径:
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit- compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/../2" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$MODULE_DIR$/../2/src/main/java" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="library" name="Maven: 2:2:1.0-SNAPSHOT" level="project" />
</component>
</module>
感谢任何帮助。如果需要任何其他文件/信息,请发表评论
答案 0 :(得分:1)
对于有类似问题的人, 我的解决方案是将两个项目都提取到可执行的jar和 使用
并行链接它们mvn install:install-file
在编译项目之前。还在依赖项下的pom文件中指定了两个jar。
在此之后,如果您尝试编译项目,maven会为您整理所有内容