I've tried to add the users and authentication with OAuth. I followed by tutorial: Video Here is his source code: https://github.com/arocketman/Spring-oauth2-jpa-example
I've done exactly like him but my Intellij showed me some issuses.
I had to change my pom.xml from
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
to
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
Just to fix "Can not resolve oauth2 symbol
in my configuration files.
But now the problem is that every getSomething
or setSomething
is marked red.
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
...
Here is my source code: https://github.com/Incybro/Spring-Blog
After installing lombok and changing imports to 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
i think you need to add lombok plugin in your IDE. to add plugin