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

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

  •  
  •   AngelFalls · 2019-03-21 12:57:53 +08:00 · 1014 次点击
    这是一个创建于 1856 天前的主题,其中的信息可能已经有所发展或是发生改变。
    下面这三种方式都能实现功能
    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   ·   我们的愿景   ·   实用小工具   ·   1011 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:28 · PVG 03:28 · LAX 12:28 · JFK 15:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.