java - How can programatically configure the @ComponentScan? -


Absence seems to establish the way in "@componentScan" to "basepackages" as programmed in.

I have something like:

  @Configuration @EnableWebMvc @ComponentScan (basePackages = "cl.pagefoo.controller") public class MyConfig extends WebMvcConfigurerAdapter {...}  

I have something like:

  foo class a {void init (SomethingContext SC) throws exception {sc.setComponentScan ( "cl.pagefoo. Controller "); }}  

I want to get this theoretical "something" square which allows the controller package to be configured in runtime

you can use WebApplicationInitializer to create the application context as the program.

  public class Starter implements WebApplicationInitializer {public void onStartup (ServletContext ServletContext) throws ServletException {AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext (); Ctx.scan ("com.package.name"); // Rest of the initialization}}  

This is an alternate way to configure web applications, so now you do not want web.xml .

Further Reading:


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -