CodexBloom - Programming Q&A Platform

Eclipse 2023-09: how to to Configure Spring Profiles in Multi-Module Maven Project

👀 Views: 13 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-05
Spring Maven Eclipse Java

Quick question that's been bugging me - I'm relatively new to this, so bear with me... I'm working with an scenario with configuring Spring profiles in my multi-module Maven project using Eclipse 2023-09. I have a parent project with several child modules, and I'm trying to set up different profiles for development and production environments. However, whenever I try to run the application with a specific profile, it defaults to the 'default' profile, ignoring my settings. Here's a snippet of my `pom.xml` in the parent project: ```xml <profiles> <profile> <id>dev</id> <properties> <spring.profiles.active>dev</spring.profiles.active> </properties> </profile> <profile> <id>prod</id> <properties> <spring.profiles.active>prod</spring.profiles.active> </properties> </profile> </profiles> ``` I run the application using the following command from the terminal: ```bash mvn clean spring-boot:run -Dspring-boot.run.profiles=dev ``` However, I see in the console output that the active profile is still set to 'default'. I have also tried setting the active profile in `application.properties` like this: ```properties spring.profiles.active=dev ``` Still, it doesn't take effect. I've verified that the profile is correctly activated when running the application from the command line, but it seems to be ignored when I run it from within Eclipse. I also checked the run configurations in Eclipse to ensure I have set the appropriate VM arguments, yet I keep seeing this message: ``` No active profile set, falling back to default profiles: default ``` Has anyone encountered this scenario before? What steps should I take to ensure that the profiles are recognized in my Eclipse environment? This is part of a larger API I'm building. What's the best practice here? What would be the recommended way to handle this? My team is using Java for this mobile app. Any examples would be super helpful.