chaof...@foxitsoftware.com, thanks for sharing your findings! It looks like CAS started using "spring.components" (and the indexer) in *v6.4.0-RC2* already - see https://github.com/apereo/cas/commit/9b98f13507c6aae101cae94f338840e02ba09330. I don't quite understand why (*the commit message says just "add indexer; fix tests" - not really helpful; moreover when there are still "org.springframework.boot.autoconfigure.AutoConfiguration.imports" files which seem to basically list the same (*Configuration) classes and all CAS beans seem to be created via @Bean methods anyway*). I also wonder if this shouldn't be documented, as this change seems to be able to break overlays which were based on an older CAS version and used the @ComponentScan annotation that no longer has the expected effect - as stated here, on SO <https://stackoverflow.com/questions/47254907/how-can-i-create-a-spring-5-component-index> and in Spring official docs <https://docs.spring.io/spring-framework/reference/core/beans/classpath-scanning.html#beans-scanning-index>? Feel free to correct me if I overlooked st. On Wednesday, 21 June 2023 at 17:20:24 UTC+2 Ray Bon wrote:
> In addition to David's links > https://fawnoos.com/2021/08/20/cas64-webflow-extensions/ > > Ray > > On Mon, 2023-06-19 at 22:36 -0700, 'Char Lin' via CAS Community wrote: > > Notice: This message was sent from outside the University of Victoria > email system. Please be cautious with links and sensitive information. > > > Hi, thank you very much for your detailed reply first. > I has tried the approach you proposed no long ago. as: > > [image: 0C683B77-DA25-4c02-B029-71AB4F233D8E.png] > > and added to > org.springframework.boot.autoconfigure.AutoConfiguration.imports. But it is > no use, these beans annotated by @Component can't create by spring still. > Of curse sure, @Bean create is correct, but my project will have so many > beans in the future, i can't @Bean them one by one... > > Now I have found the solution to this problem. > It is missing a file at > ./build/classes/java/main/META-INF/spring.components. > but all modules of CAS7.0.0 exist this file, so these beans created by > myself won't be scanned. > > Just inject the following dependencies at build.gradle then compile or > build project, it will automatically generate 'spring.components' file: > [image: BAAD5B16-5AB2-408b-8206-D13EC90757FD.png] > > 在2023年6月20日星期二 UTC+8 11:51:44<David Malia> 写道: > > This isn't really a CAS issue, but rather understanding how Spring > configuration works. > > Create a Spring configuration class with the following annotations > adjusting accordingly to your environment. > > package some.package; > @Configuration > @ComponentScan(basePackages = > {"some.package.you.want.scanned","some.other.package.you.want.scanned"}) > > @EnableConfigurationProperties(CasConfigurationProperties.class) > public class YourSpringConfigurationClass { > @Autowired > private CasConfigurationProperties casProperties; > . > . > //you can choose to create beans here as well. > . > } > > In your MyAuthenticationHandler class, add the annotation @Component to > it. This will allow the @ComponentScan annotation to find your bean, and > create it. > > In the jar file where your class lives, > add a folder META-INF, and a spring.factories file in it. > It typically would live in at src/main/resources/META-INF/spring.factories > inside your source directory. > > In the spring.factories file, add the line > org.springframework.boot.autoconfigure.EnableAutoConfiguration=some.package.YourSpringConfigurationClass, > > some.package.AnotherSpringConfigurationClassIfNeeded > > This tells Spring where to find your Spring configuration class. > > > > *References*: > > https://dzone.com/articles/apereo-cas-step-by-step-guide-to-implement-a-custom-authentication-handler > > https://docs.spring.io/spring-boot/docs/2.0.0.M3/reference/html/boot-features-developing-auto-configuration.html > https://www.baeldung.com/spring-component-scanning > > > > > On Mon, Jun 19, 2023 at 5:38 AM 'Char Lin' via CAS Community < > cas-...@apereo.org> wrote: > > Hi, all. > Just like the title, CAS 7.0.0, I can't atowired the bean annotated by > @Service and @Component... How to configure scan them and add to spring > bean factories? > > [image: 20230619181953.png] > From the picture, I started the cas application, but report the > 'userService is null' > who can help me, thank you very much! > > > -- > - Website: https://apereo.github.io/cas > - Gitter Chatroom: https://gitter.im/apereo/cas > - List Guidelines: https://goo.gl/1VRrw7 > - Contributions: https://goo.gl/mh7qDG > --- > You received this message because you are subscribed to the Google Groups > "CAS Community" group. > To unsubscribe from this group and stop receiving emails from it, send an > email tocas-user+u...@apereo.org. > To view this discussion on the web visit > https://groups.google.com/a/apereo.org/d/msgid/cas-user/68985f35-fdd1-4077-8f06-612ea0331959n%40apereo.org > > <https://groups.google.com/a/apereo.org/d/msgid/cas-user/68985f35-fdd1-4077-8f06-612ea0331959n%40apereo.org?utm_medium=email&utm_source=footer> > . > > > -- - Website: https://apereo.github.io/cas - Gitter Chatroom: https://gitter.im/apereo/cas - List Guidelines: https://goo.gl/1VRrw7 - Contributions: https://goo.gl/mh7qDG --- You received this message because you are subscribed to the Google Groups "CAS Community" group. To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+unsubscr...@apereo.org. To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/61a67584-f03e-4095-b982-247f5f61bb4bn%40apereo.org.