java - spring profile groups -
i have application, can specify profiles want run on. want grouping these profiles things credentails, application performance, memory-print, application behaviour etc. ex. can run next profiles
-dspring.profiles.active=production,cached-local,db-connection-pooled...
but prefer initializing as
-dspring.profiles.active=production,super-fast #the above activates method level caches, db connection pooling etc #super-fast triggered activation of cached-local, db-connection-pooled profiles
or
-dspring.profiles.active=dev,low-footprint #the above dosent enable caching, or db connection pooling
can achieved without writing custom code how set active spring 3.1 environment profile via properites file , not via env variable or scheme property. fine if can load these properties files or within spring-xml config. using xml config on spring 3.1.
i don't know of way accomplish without custom code manipulate active profiles in configurableenvironment
.
we're trying accomplish same indirection pattern rights vs. roles (group of rights) in security framework, since doesn't come out of box, ended having work around it.
i kept profiles general, e.g. production , super-fast in case, , each bean sensitive profiles, set right @profile. create refactoring easier, used 2 techniques.
create meta-annotation each profile, e.g.@production
, @superfast
, create profile name public constant, e.g. production.profile_name = "production"
. when marking profile of bean, utilize new meta-annotation if applies 1 profile, or utilize @profile({production.profile_name, ...})
if applies multiple profiles. have because can't apply 2 profile meta-annotations same bean, at to the lowest degree not until 4.0. for example,
@profile(production.profile_name) public @interface production { public static string profile_name = "production"; }
the point of can utilize ide usages of @production
or production.profile_name
if need understand or alter beans beingness pulled in.
java spring profiles spring-profiles
No comments:
Post a Comment