gpt4 book ai didi

java - 找不到@Getter和@Setter

转载 作者:行者123 更新时间:2023-12-01 17:44:49 24 4
gpt4 key购买 nike

我尝试使用 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 符号”。

但现在的问题是每个 getSomethingsetSomething 都被标记为红色。

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

最佳答案

我认为您需要在 IDE 中添加 lombok 插件。添加插件

  • 转到"file">“设置”>“插件”
  • 点击浏览存储库...
  • 搜索 Lombok 插件
  • 点击安装插件
  • 重新启动 IntelliJ IDEA

see here for details

for more details

关于java - 找不到@Getter和@Setter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56787143/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com