He intentado agregar los usuarios y la autenticación con OAuth. Seguí por tutorial: video Aquí está su código fuente: https://github.com/arockman/spring-oauth2- Ejemplo de JPA

Lo he hecho exactamente como él, pero mi IntelliJ me mostró algunos problemas.

Tuve que cambiar mi pom.xml de

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>

Para

        <dependency>
            <groupId>org.springframework.security.oauth.boot</groupId>
            <artifactId>spring-security-oauth2-autoconfigure</artifactId>
            <version>2.1.6.RELEASE</version>
        </dependency>

Sólo para arreglar "no puede resolver oauth2 symbol en mis archivos de configuración.

Pero ahora el problema es que cada getSomething o setSomething está marcado en rojo.

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
...

Aquí está mi código fuente: https://github.com/incybro/spring-blog

Después de instalar Lombok y cambiar las importaciones a 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
Eliro 27 jun. 2019 a las 11:38

1 respuesta

La mejor respuesta

Creo que necesitas agregar plugin de Lombok en tu IDE. Para agregar complemento

  • Ir a Archivo> Configuraciones> Complementos
  • Haga clic en Examinar repositorios ...
  • Búsqueda de plugin de Lombok
  • Haga clic en Instalar complemento
  • Reinicie IntelliJ IDEA

ver aquí para más detalles

para más detalles

4
Istiaque Hossain 27 jun. 2019 a las 08:43