Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用户实体-找不到符号_Java_Spring_Maven_Intellij Idea_Oauth 2.0 - Fatal编程技术网

Java 用户实体-找不到符号

Java 用户实体-找不到符号,java,spring,maven,intellij-idea,oauth-2.0,Java,Spring,Maven,Intellij Idea,Oauth 2.0,我正在尝试使用OAuth设置用户和身份验证。 我所有的源代码都在这里: 我在Intellij IDEA中安装了lombok插件,重新启动了IDE,但出现了一些错误: 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.Resou

我正在尝试使用OAuth设置用户和身份验证。 我所有的源代码都在这里:

我在Intellij IDEA中安装了lombok插件,重新启动了IDE,但出现了一些错误:

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
在这方面:

public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

没有东西是红色的。我无法启动我的应用程序。源代码是从

修复您的
ResourceServerConfig
类复制的。使用下面的代码

@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
而不是

public class ResourceServerConfig {

@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {

第一个错误
错误:(12,12)java:class com.github.Spring.Blog.config.ResourceServerConfig已经在包com.github.Spring.Blog.config
中定义,可以通过从
com.github.Spring.Blog.config.ResourceServerConfig
中删除外部类来解决,因此文件中只剩下带注释的类。对于缺少的getter:您启用了设置中的注释处理?
  @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return repo
                .findByUsername(username)
                .map(u -> new org.springframework.security.core.userdetails.User(
                        u.getUsername(),
                        u.getPassword(),
                        u.isActive(),
                        u.isActive(),
                        u.isActive(),
                        u.isActive(),
                        AuthorityUtils.createAuthorityList(
                                u.getRoles()
                                        .stream()
                                        .map(r -> "ROLE_" + r.getName().toUpperCase())
                                        .collect(Collectors.toList())
                                        .toArray(new String[]{}))))
                .orElseThrow(() -> new UsernameNotFoundException("No user with "
                        + "the name " + username + "was found in the database"));
    }

}
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
public class ResourceServerConfig {

@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {