eclipse @slf4j log 无法解析

转载自:https://blog.csdn.net/icecoola_/article/details/77414572

lombok官方网站:https 
//projectlombok.org/ jar包下载路径:https: 
//projectlombok.org/download lombok功能:https//projectlombok.org/features/all

lombok:通过注解方式减少POJO类的getter和setter等方法来消除冗余代码量
  • 1

安装 
1.下载lombok.jar 
2.官网说是可以双击安装,,,我用这种方法不可行 
2.手动安装 
(1)将lombok.jar移到eclipse的安装目录 
这里写图片描述

(2)在eclipse.in文件最后加入下面两行

-Xbootclasspath/a:lombok.jar
-javaagent:lombok.jar
  • 1
  • 2

============= 
-javaagent:xxx.jar的jar名称需要与根目录下的jar名一致, 
不一致,可能会出现eclipse无法启动的情况。

(3)重启蚀,进行代码测试

原始的Java代码:

public class NoteTest {

    private int noteId;
    private String title;
    private String content;
    private int typeId;

}

类文件反编译后:

public class NoteTest
{

    private int noteId;
    private String title;
    private String content;
    private int typeId;

    public NoteTest()
    {

加入龙目岛注解后的java的代码:

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString(exclude="typeId")
public class NoteTest {

    private int noteId;
    private String title;
    private String content;
    private int typeId;

}

加注解,经反编译:

public class NoteTest
{

    private int noteId;
    private String title;
    private String content;
    private int typeId;

    public int getNoteId()
    {
        return noteId;
    }

    public String getTitle()
    {
        return title;
    }

    public String getContent()
    {
        return content;
    }

    public int getTypeId()
    {
        return typeId;
    }

    public void setNoteId(int noteId)
    {
        this.noteId = noteId;
    }

    public void setTitle(String title)
    {
        this.title = title;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    public void setTypeId(int typeId)
    {
        this.typeId = typeId;
    }

    public boolean equals(Object o)
    {
        if (o == this)
            return true;
        if (!(o instanceof NoteTest))
            return false;
        NoteTest other = (NoteTest)o;
        if (!other.canEqual(this))
            return false;
        if (getNoteId() != other.getNoteId())
            return false;
        Object this$title = getTitle();
        Object other$title = other.getTitle();
        if (this$title != null ? !this$title.equals(other$title) : other$title != null)
            return false;
        Object this$content = getContent();
        Object other$content = other.getContent();
        if (this$content != null ? !this$content.equals(other$content) : other$content != null)
            return false;
        return getTypeId() == other.getTypeId();
    }

    protected boolean canEqual(Object other)
    {
        return other instanceof NoteTest;
    }

    public int hashCode()
    {
        int PRIME = 59;
        int result = 1;
        result = result * 59 + getNoteId();
        Object $title = getTitle();
        result = result * 59 + ($title != null ? $title.hashCode() : 43);
        Object $content = getContent();
        result = result * 59 + ($content != null ? $content.hashCode() : 43);
        result = result * 59 + getTypeId();
        return result;
    }

    public NoteTest()
    {
    }

    public NoteTest(int noteId, String title, String content, int typeId)
    {
        this.noteId = noteId;
        this.title = title;
        this.content = content;
        this.typeId = typeId;
    }

    public String toString()
    {
        return (new StringBuilder("NoteTest(noteId=")).append(getNoteId()).append(", title=").append(getTitle()).append(", content=").append(getContent()).append(")").toString();
    }
}

在项目中:

日志还是无法解析,就清理一下项目。

日食中清理项目:


清理完后,就可以了,不然编译没问题,项目一跑就出事。
转载自:https://blog.csdn.net/icecoola_/article/details/77414572
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用中提到了使用log.info()方法需要依赖slf4j-api。而引用中提到了在使用lombok的@Slf4j注解打印日志文件时,可能会遇到log.info()无法使用的问题。针对这个问题,有几种解决方案。一种是在项目的依赖中添加slf4j-api的依赖项,确保使用log.info()的代码能够正确引用到这个方法。另外,也可以尝试在IDE中下载Lombok插件,这可能有助于解决使用@Slf4j注解打印日志时的问题。最后,引用中提到了处理slf4j日志使用的基本错误的方法,其中包括导入slf4j-api和slf4j-log4j12等包。根据这些信息,我建议您检查项目的依赖项,确保正确导入了所需的包,并检查IDE中是否已正确配置Lombok插件。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [IDEA解决@Slf4jlog报红](https://blog.csdn.net/weixin_43707759/article/details/118215226)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [使用@Slf4j注解,log.info()无法使用](https://blog.csdn.net/zhen_hh/article/details/120653159)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [SLF4J日志报错解决办法](https://download.csdn.net/download/devilnumber/10650086)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值