I am new to CAS codebase.
Would really appreciate some pointers?
Initialized cas overlay project from .html
I am trying to add my own own class with annotation @SpringBootApplication
so that it scans my packages for bean initialization and Controller class so that i can override functions of cas overlay.
I modified main entry class here .gradle#L81
I can see this in the logs
2025-01-18 08:48:11,371 DEBUG [.springframework.boot.devtools.restart.Restarter] - <Starting application com.test.AuthenticationApplication with URLs [file:/Users/Desktop/AE/ae_authentication-service/src/main/resources/, file:/Users/Desktop/AE/ae_authentication-service/build/classes/java/main/, file:/Users/Desktop/AE/ae_authentication-service/build/resources/main/]>
but why is it not scanning other packages.
Am i missing something
I am new to CAS codebase.
Would really appreciate some pointers?
Initialized cas overlay project from https://apereo.github.io/cas/development/installation/WAR-Overlay-Initializr.html
I am trying to add my own own class with annotation @SpringBootApplication
https://github/apereo/cas-overlay-template/tree/master/src/main so that it scans my packages for bean initialization and Controller class so that i can override functions of cas overlay.
https://github/apereo/cas-overlay-template/tree/master/src/main
I modified main entry class here https://github/apereo/cas-overlay-template/blob/master/gradle/springboot.gradle#L81
I can see this in the logs
2025-01-18 08:48:11,371 DEBUG [.springframework.boot.devtools.restart.Restarter] - <Starting application com.test.AuthenticationApplication with URLs [file:/Users/Desktop/AE/ae_authentication-service/src/main/resources/, file:/Users/Desktop/AE/ae_authentication-service/build/classes/java/main/, file:/Users/Desktop/AE/ae_authentication-service/build/resources/main/]>
but why is it not scanning other packages.
Am i missing something
Share Improve this question asked Jan 18 at 14:03 user29218322user29218322 31 bronze badge 1- Hi, I think your question needs some cleanup (e.g. what does linking to github/apereo/cas-overlay-template/tree/master/src/main twice mean?). Anyway, I've tried to answer your question. There should be no need to define your own main entry class / @SpringBootApplication for adding a custom REST controller to CAS. – Petr Bodnár Commented Jan 19 at 10:39
1 Answer
Reset to default 0The problem is that in CAS version 7, authors (AFAIK quietly) decided to disable Spring's automatic scanning/discovery of annotated components, probably for performance reasons. Instead, CAS relies on Spring's Component Indexer now. Even though it looks like all its components are still being created in Java via @Bean
methods, so there should be no components scanning or indexing necessary for CAS own components anyway.
Source: CAS 7.0.0, how to scan self created beans, and manage by spring
So, the solution is either to create your component (whether it is RestController
or anything else) as CAS does it, i.e. in your own Java Spring configuration class (which is documented at Extending CAS Configuration).
Or, try to put the name of your component class into the META-INF/springponents
file in your project, which you might want to automate by using the Spring indexer tools discussed in the SO page linked above. The current format of one line in that file seems to be something like .example.YourComponentClass=.springframework.stereotype.Component
(value after the =
sign might generally differ).