我尝试用OAuth添加用户和身份验证。我紧随其后的是教程:Video 这是他的源代码:https://github.com/arocketman/Spring-oauth2-jpa-example
我的表现完全和他一样,但是我的Intellij告诉我一些问题。
我不得不从以下位置更改我的pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
到
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
只需修复“无法解析我的配置文件中的oauth2 symbol
。
但是现在的问题是,每个getSomething
或setSomething
都标记为红色。
Error:(12, 12) java: class com.github.Spring.Blog.config.ResourceServerConfig is already defined in package com.github.Spring.Blog.config
Error:(3, 48) java: package jdk.nashorn.internal.objects.annotations does not exist
Error:(4, 48) java: package jdk.nashorn.internal.objects.annotations does not exist
Error:(18, 2) java: cannot find symbol
symbol: class Getter
Error:(19, 2) java: cannot find symbol
symbol: class Setter
Error:(3, 48) java: package jdk.nashorn.internal.objects.annotations does not exist
Error:(4, 48) java: package jdk.nashorn.internal.objects.annotations does not exist
Error:(14, 2) java: cannot find symbol
symbol: class Getter
Error:(15, 2) java: cannot find symbol
symbol: class Setter
...
这是我的源代码:https://github.com/Incybro/Spring-Blog
在安装lombok并将导入更改为import lombok.*;
C:\Users\Admin\Desktop\Spring-Blog\src\main\java\com\github\Spring\Blog\config\ResourceServerConfig.java
Error:(12, 12) java: class com.github.Spring.Blog.config.ResourceServerConfig is already defined in package com.github.Spring.Blog.config
C:\Users\Admin\Desktop\Spring-Blog\src\main\java\com\github\Spring\Blog\services\UserService.java
Error:(20, 53) java: cannot find symbol
symbol: method getPassword()
location: variable user of type com.github.Spring.Blog.entities.User
C:\Users\Admin\Desktop\Spring-Blog\src\main\java\com\github\Spring\Blog\SpringBlogApplication.java
Error:(27, 55) java: constructor Role in class com.github.Spring.Blog.entities.Role cannot be applied to given types;
required: no arguments
found: java.lang.String
reason: actual and formal argument lists differ in length
Error:(27, 73) java: constructor Role in class com.github.Spring.Blog.entities.Role cannot be applied to given types;
required: no arguments
found: java.lang.String
reason: actual and formal argument lists differ in length
C:\Users\Admin\Desktop\Spring-Blog\src\main\java\com\github\Spring\Blog\services\CustomUserDetailsService.java
Error:(29, 26) java: cannot find symbol
symbol: method getUsername()
location: variable u of type com.github.Spring.Blog.entities.User
Error:(30, 26) java: cannot find symbol
symbol: method getPassword()
location: variable u of type com.github.Spring.Blog.entities.User
Error:(31, 26) java: cannot find symbol
symbol: method isActive()
location: variable u of type com.github.Spring.Blog.entities.User
Error:(32, 26) java: cannot find symbol
symbol: method isActive()
location: variable u of type com.github.Spring.Blog.entities.User
Error:(33, 26) java: cannot find symbol
symbol: method isActive()
location: variable u of type com.github.Spring.Blog.entities.User
Error:(34, 26) java: cannot find symbol
symbol: method isActive()
location: variable u of type com.github.Spring.Blog.entities.User
Error:(36, 34) java: cannot find symbol
symbol: method getRoles()
location: variable u of type com.github.Spring.Blog.entities.User
答案 0 :(得分:4)
我认为您需要在IDE中添加lombok插件。 添加插件