spring-cloud / spring-cloud/spring-cloud-config
Spring Profile Active is not setting
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2k
- Forks
- 1.3k
- Avg merge
- 2d 59m
- Merged PRs (30d)
- 16
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MainClass entry point and run the exact java command shown, comparing the system property with ctx.getEnvironment().getActiveProfiles(). Trace SpringApplication.run and the packaged application's startup configuration to identify why the profile is not carried into the environment; done means documenting or reproducing the cause and confirming the active profile is set.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100