Spring boot: apply @Configuration to certain package only

Viewed 8213

I am using @Configuration to config cookies, while in my project there is 2 packages and I only want to apply the config to one of the package.
Are there any ways to set the target package for @Configuration?

package structure:
--app
----packageA
------MyConfigClass.java
----packageB

@EnableJdbcHttpSession(maxInactiveIntervalInSeconds = 1800)
@Configuration
public class MyConfigClass extends WebMvcConfigurerAdapter {
@Bean
    public CookieSerializer cookieSerializer() {
        // I want the follow cookie config only apply to packageA
        DefaultCookieSerializer serializer = new DefaultCookieSerializer();
        serializer.setCookieName("myCookieName");
        serializer.setCookiePath("/somePath/");
        return serializer;
    }
}
4 Answers
Related