简体   繁体   中英

autowiring with a specific application.properties

I want to use an interface with multiple implementations and a lot of different application.properties. If the active application-a.properties he should autowire the implementation a otherwise b. So I got an interface like this:

public interface ab {
void dosomething();
}

and the classes:

public a() implements ab{
@Override
void do something(){
    System.out.println("Hello here is a");
}
public b() implements ab{
@Override
void do something(){
    System.out.println("Hello here is b");
}

I know there is the @Profile() notation, but is there something like @Profile(!"a")?

but is there something like @Profile(!"a")? doc

If a given profile is prefixed with the NOT operator (!), the annotated component will be registered if the profile is not active — for example, given @Profile({"p1", "!p2"}), registration will occur if profile 'p1' is active or if profile 'p2' is not active.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM