V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
AngelFalls
V2EX  ›  Java

关于 springboot 几种调用方式的困惑

  •  
  •   AngelFalls · 2019 年 3 月 21 日 · 1303 次点击
    这是一个创建于 2508 天前的主题,其中的信息可能已经有所发展或是发生改变。
    下面这三种方式都能实现功能
    JwtLoginRequestSuccessHandler 与 JwtUserService 都已在 config 中注册为 Bean
    请教各位大佬这三种方式的优缺点以及大佬们经常使用哪种方式
    谢谢


    [方式一]
    public class JwtLoginRequestSuccessHandler implements AuthenticationSuccessHandler {
    ...

    private JwtUserService jwtUserService;

    public JwtLoginRequestSuccessHandler(JwtUserService jwtUserService) {
    this.jwtUserService = jwtUserService;
    }
    ...
    }

    [方式二]
    public class JwtLoginRequestSuccessHandler implements AuthenticationSuccessHandler {
    ...

    @Autowired
    private JwtUserService jwtUserService;

    ...
    }

    [方式三]
    public class JwtLoginRequestSuccessHandler implements AuthenticationSuccessHandler {
    ...

    private JwtUserService jwtUserService;

    @Autowired
    public JwtLoginRequestSuccessHandler(JwtUserService jwtUserService) {
    this.jwtUserService = jwtUserService;
    }
    ...
    }
    目前尚无回复
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   853 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:39 · PVG 05:39 · LAX 13:39 · JFK 16:39
    ♥ Do have faith in what you're doing.