【发布时间】:2014-12-03 15:14:02
【问题描述】:
我有一个带有两个子模块(module1 和 module2)的父模块
module2 具有对 module1 的 maven 依赖项
在module2 中,我引用了module1 中的一个类
当我尝试跳转到此类的定义时,IntelliJ 在我的 maven 存储库中打开 .class 文件。我希望它跳转到module1 中的java 类。如何让 IntelliJ 跳转这个类文件?
我正在运行 IntelliJ IDEA Ultimate 14.0.1
parentpom:
<?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>test</groupId>
<artifactId>test</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>module2</module>
<module>module1</module>
</modules>
</project>
module1pom:
<?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>test</artifactId>
<groupId>test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>module1</artifactId>
</project>
module2pom:
<?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>test</artifactId>
<groupId>test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>module2</artifactId>
<dependencies>
<dependency>
<groupId>test</groupId>
<artifactId>module1</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
【问题讨论】:
-
请向我们展示你的 pom 文件,全部三个
-
我已将 pom 文件添加到问题中
-
好的,你的 pom 看起来是正确的,所以 Idea 应该能够使用它并让你在模块中的类之间直接导航。你是如何打开项目的?最好在所有项目关闭的情况下开始idea,配置maven,然后使用file/open 导入主pom。然后,转到模块 2 中引用模块 1 中的类的类,并尝试导航(按住 ctrl 单击)类名。
-
还有,您的 java 是否在标准 maven 目录结构中:
src/main/java/...? -
我已经尝试再次重现该问题,但我再也无法重现了。上周我一直在摆弄 IntelliJ 中的 maven 设置,显然我已经解决了这个问题。我现在可以正常 CTRL+单击。感谢您对工程师 Dollery 的所有帮助 :)
标签: maven intellij-idea intellij-14