简体   繁体   中英

Maven run configuration doesn't pick up active profile while Spring run configuration does

My Spring run configuration is just the default with the following the VM options:

-Dspring.profiles.active=local

My Maven run configuration is the defaults with the following in the command line:

spring-boot:run

and the following in VM options:

-Dspring.profiles.active=local

When I run the maven one it doesn't pick up on a profile and instead uses default:

No active profile set, falling back to default profiles: default

With the Spring configuration I have no issues, the problem is with how I need to deploy it, it uses a maven command, so I can't have this failing and I don't really understand why it's happening. There really isn't anything fancy is this projects. It's your basic micro service.

Just in case it's needed. The root 'Application' file only has the following:

@SpringBootApplication
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}

Link to the Maven run config. It is all defaults outside of what is pictured. https://imgur.com/a/GGiwimQ

Adding the following to the command line arguments seemed to fix it:

-Drun.jvmArguments=-Dspring.profiles.active=local

Although I understand why it worked it doesn't explain why this happened in the first place. I will update this answer if I ever find out the true reason.

create

application.properties

file in src/main/resources if it doesnt exist and add

spring.profiles.active=local

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