Maven的编译错误:无法找到与当地的依赖条件符号(Maven Compilation error:

2019-10-21 00:56发布

当我运行“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,我进口,代码为“红”,也就是说它可以将其解析为jar文件。 但是,当我运行mvn编译它说“无法找到符号”。 更重要的是令人沮丧的是,如果我做同样的事情在Eclipse中,它工作正常,但在的IntelliJ它没有。 问题是什么? 这让我疯狂。

Answer 1:

按住Ctrl键并单击Person类上SeniorSurveyPortlet的4线。

你应该看到的IntelliJ窗口标题的文件位置。

该位置应该是在本地Maven回购的工件(即一个名为.m2目录的目录)。

路径包含的groupId,artifactId和version。

确保关系在POM中正确列出。



文章来源: Maven Compilation error: cannot find symbol with local dependecies