【问题标题】:Intellij can not resolve class of external libraryIntellij 无法解析外部库的类
【发布时间】:2018-02-27 09:47:54
【问题描述】:

需要帮助!

我正在尝试使用 Maven 将 spring 安全库连接到我的项目。

<dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>4.2.3.RELEASE</version>
    </dependency>


    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>4.2.3.RELEASE</version>
    </dependency>

库org.springframework.security.core已经下载成功。

But when i'm trying to extend my class(AuthorizedUser.class) from org.springframework.security.core.userdetails.User Intellij says, that can not resolve it. But other classes and interfaces from: org.springframework.security.core.userdetails resolving well. See the link...

When i goes to external library tree and opened org.springframework.security.core.userdetails library i saw User.class like this See the link...

如果有人知道这个问题,我将非常感谢您提供任何信息

Windows 7

Intellij IDEA 版本 2017.2.4 Ultimate

Java 版本 1.8.0_144

Maven 版本 3.5.0

【问题讨论】:

标签: java maven intellij-idea spring-security


【解决方案1】:

也许,你只需要创建一个与超类匹配的构造函数,或者首先尝试创建一个类属性,而不是仅仅为了测试而扩展它。 apidoc

如果没有帮助,可能与 ide 无关,可能是由于配置错误,maven 无法解析依赖关系。

你可以试试这些:

1-检查本地maven存储库并确认jar文件的正确版本。

c:\users{用户名}.m2\repository\org\springframework\security

2- 尝试使用以下命令从命令行构建并确认构建成功完成

mvn 全新安装

3- 尝试重新导入所有 maven 项目

4 - 另外,确认 intellij 使用正确的 maven 版本、存储库和设置 xml。您可以在搜索栏上写“maven settings”,它会引导您进入 maven 设置页面。

如果您发现其中任何一个不符合预期,请告诉我,我会尽力提供帮助。

【讨论】:

  • 感谢您的回答。但是我已经完成了您之前在上面描述的所有操作,并且没有任何改变。 Maven 依赖项很好地解决并且 Maven 编译成功。问题是 org.springframework.security.core.userdetails 库的 User.class 没有解析。当我尝试在 IDEA 中打开它时,我看到了符号(第一个链接上的屏幕)...
猜你喜欢
  • 2017-04-25
  • 1970-01-01
  • 2020-11-10
  • 1970-01-01
  • 2019-02-27
  • 2018-05-28
  • 1970-01-01
  • 1970-01-01
  • 2017-08-16
相关资源
最近更新 更多