How to set a Spring profile to a package?

前端 未结 2 1812
广开言路
广开言路 2021-01-19 16:31

I want to set a profile name to a whole package and I don\'t know how. If where is no easy way then I have to mark every class in the package and sub packages with @Pr

2条回答
  •  长情又很酷
    2021-01-19 16:48

    You can set profile for:

    • Spring Beans XML file - for xml configuration
    
    
    
        
    
    
    • @Configuration class for Java config
    @Configuration
    @Profile("your-profile")
    @Componentscan("your.package")
    class AppConfig {
    }
    

    In each of them you can use component scanning for your a particular package.

提交回复
热议问题