当我跑步" mvn编译"在我的Maven项目中,我收到如下错误消息:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/rommelrico/Documents/GitHub/github.sandiego.edu/SeniorSurvey/src/main/java/edu/sandiego/custom/SeniorSurveyPortlet.java:[4,37] cannot find symbol
symbol : class Person
location: package com.sghe.luminis.person.entity
我安装了一组闭源文件,如下所示:
mvn install:install-file -Dfile=aspectjrt.jar -DgroupId=some.group -DartifactId=aspectjrt -Dversion=1 -Dpackaging=jar
当我列出Maven依赖项时,它们看起来很好(没有错误):
[INFO] ------------------------------------------------------------------------
[INFO] Building SeniorSurvey Portlet 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ SeniorSurveyPortlet ---
[INFO]
[INFO] The following files have been resolved:
[INFO] some.group:util-taglib:jar:1:compile
[INFO] some.group:sqljdbc4:jar:1:compile
[INFO] some.group:util-java:jar:1:compile
[INFO] some.group:luminis-security-base:jar:1:compile
[INFO] com.googlecode.json-simple:json-simple:jar:1.1:compile
[INFO] commons-logging:commons-logging:jar:1.1.1:compile
[INFO] some.group:luminis-security-policy:jar:1:compile
[INFO] log4j:log4j:jar:1.2.12:compile
[INFO] javax.servlet:jstl:jar:1.1.2:compile
[INFO] some.group:util-bridges:jar:1:compile
[INFO] some.group:aspectjrt:jar:1:compile
[INFO] some.group:luminis-session:jar:1:compile
[INFO] org.json:json:jar:20090211:compile
[INFO] some.group:luminis-dal:jar:1:compile
[INFO] taglibs:standard:jar:1.0.4:compile
[INFO] some.group:spring-2.5.5:jar:1:compile
[INFO] xml-apis:xml-apis:jar:1.0.b2:compile
[INFO] some.group:jasig-cas-client-core-3.1.3:jar:1:compile
[INFO] some.group:spring-security-cas-client-2.0.5.RELEASE:jar:1:compile
[INFO] some.group:spring-security-core-2.0.5.RELEASE-mod:jar:1:compile
[INFO] org.jsoup:jsoup:jar:1.7.2:compile
[INFO] some.group:luminis-person:jar:1:compile
[INFO] com.sun.jersey:jersey-client:jar:1.8:compile
[INFO] com.sun.jersey:jersey-core:jar:1.8:compile
[INFO] xalan:xalan:jar:2.6.0:compile
[INFO] some.group:luminis-util:jar:1:compile
[INFO] some.group:luminis-security-springweb:jar:1:compile
[INFO] org.apache.portals.pluto:pluto-taglib:jar:2.0.0:provided
[INFO] javax.servlet:servlet-api:jar:2.4:compile
[INFO] javax.portlet:portlet-api:jar:2.0:provided
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.177 s
[INFO] Finished at: 2014-09-24T12:02:59-08:00
[INFO] Final Memory: 8M/81M
[INFO] ------------------------------------------------------------------------
我的POM依赖项:
<dependencies>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.portals.pluto</groupId>
<artifactId>pluto-taglib</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>aspectjrt</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>jasig-cas-client-core-3.1.3</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>luminis-dal</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>luminis-person</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>luminis-security-base</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>luminis-security-policy</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>luminis-security-springweb</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>luminis-session</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>luminis-util</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>spring-2.5.5</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>spring-security-cas-client-2.0.5.RELEASE</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>spring-security-core-2.0.5.RELEASE-mod</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>sqljdbc4</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>util-bridges</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>util-java</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.group</groupId>
<artifactId>util-taglib</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
</dependencies>
我的IntelliJ设置:
在IntelliJ中,我的导入和代码不是&#34; red&#34;这意味着它可以将其解析为jar文件。但是当我运行mvn编译它时说&#34;找不到符号&#34;。更令人沮丧的是,如果我在Eclipse中做同样的事情,它可以正常工作,但在IntelliJ中它并没有。问题是什么?它让我发疯了。
答案 0 :(得分:1)
按住CTRL并点击SeniorSurveyPortlet第4行的人员类。
您应该在IntelliJ窗口标题中看到文件位置。
该位置应该是本地maven仓库中的工件(即名为.m2的目录)。
该路径包含groupId,artifactId和version。
确保在pom中正确列出了依赖关系。