V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
nihaorz
V2EX  ›  问与答

通过 spring.factories 添加的配置类中指定包扫描路径无效

  •  1
     
  •   nihaorz · Mar 7, 2022 · 1342 views
    This topic created in 1517 days ago, the information mentioned may be changed or developed.

    正在做 CAS-6.5.0 的集成修改,我要添加自己的 Controller

    https://s1.ax1x.com/2022/03/07/bsmHjx.png

    通过 spring.factories 添加了我的 ComponentScanConfig 作为配置扫描入口,使用 @PostConstruct 注解的 init 成功执行。但是 basePackages 参数中添加的包扫描路径下的 Controller 没扫描出来

    https://s1.ax1x.com/2022/03/07/bsmBNQ.png

    https://s1.ax1x.com/2022/03/07/bsQOtU.png

    在 CAS 完全启动完毕后我使用 applicationContext.getBeanDefinitionNames() 获取所有的 bean ,一个一个的打印名字,确认了确实是没有成功注入我配置的扫描路径下的 Controller 、Service 等

    在之前做 CAS-5.x 的集成时还可以这样成功添加我自己的 Controller 、Service ,求各位彦祖搞定过类似问题的指导一下小弟,万谢!

    https://s1.ax1x.com/2022/03/07/bsMjsI.jpg

    nihaorz
        1
    nihaorz  
    OP
       Mar 7, 2022
    具体版本:
    spring-boot-2.6.3
    spring-core-5.3.15
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2598 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 14:10 · PVG 22:10 · LAX 07:10 · JFK 10:10
    ♥ Do have faith in what you're doing.