I'm trying to setup the users and authentication with OAuth. All my source code is here: https://github.com/Incybro/Spring-Blog
I installed lombok plugin in my Intellij IDEA, restarted IDE but there are some errors:
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
In this lines:
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
public void save(User user){
user.setPassword(passwordEncoder.encode(user.getPassword()));
repo.save(user);
}
@Bean
public CommandLineRunner setupDefaultUser(UserService service) {
return args -> {
service.save(new User(
"user", //username
"user", //password
Arrays.asList(new Role("USER"), new Role("ACTUATOR")),//roles
true//Active
));
};
}
@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"));
}
}
Nothing is marked red. I can not start my app. Source code was copied from https://www.youtube.com/watch?v=IOgCMtYMr2Q&list=PLcoE64orFoVsxAam_BuQBrNC8IO238SwH&index=2