Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Profile Active is not setting #2391

Open
mrvaruntandon opened this issue Mar 13, 2024 · 0 comments
Open

Spring Profile Active is not setting #2391

mrvaruntandon opened this issue Mar 13, 2024 · 0 comments

Comments

@mrvaruntandon
Copy link

I am trying to run the below command to start a springboot application

java -Dlog4j.configuration=file:///log4j.properties -Dspring.profiles.active=local -cp ./target/app-1.0.0-SNAPSHOT-jar-with-dependencies.jar MainClass

the jar above is prepared using maven-assembly-plugin the configuration for which is

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>${maven-assembly-plugin.version}</version>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
            <manifest>
                <mainClass>MainClass</mainClass>
            </manifest>
        </archive>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Main class looks like

@SpringBootApplication
@Slf4j
public class MainClass {
    public static void main(String... args) {
        log.info(System.getProperty("spring.profiles.active"));
        ApplicationContext ctx = SpringApplication.run(AcctrvDataProcessor.class, args);
        log.info(Arrays.toString(ctx.getEnvironment().getActiveProfiles()));
        int exitCode = SpringApplication.exit(ctx);
        System.exit(exitCode);
    }
}

When I run the application from the above command I am seeing the below log:

15:45:07.091 [main] INFO MainClass - local
15:46:07.091 [main] INFO MainClass - No active profile set, falling back to 1 default profile: "default"

What could be preventing the spring profile actives from being set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant