lunedì 2 marzo 2020

Spring boot multiple property files



Add in pom:

<build>
...
  <resources>
   <resource>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
   </resource>
  </resources>
...
</build>



  1. Add

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-help-plugin</artifactId>
    <version>3.2.0</version>
     <executions>
      <execution>
       <id>show-profiles</id>
        <phase>compile</phase>
        <goals>
         <goal>active-profiles</goal>
        </goals>
      </execution>
     </executions>
</plugin>




  1. Add

<profiles>
  <profile>
   <id>dev</id>
    <properties>
     <activatedProperties>dev</activatedProperties>
    </properties>
    <activation>
     <activeByDefault>true</activeByDefault>
    </activation>
  </profile>
  <profile>
  <id>prod</id>
   <properties>
     <activatedProperties>prod</activatedProperties>
   </properties>
  </profile>
</profiles>



  1. Create application.properties:

spring.profiles.active=@activatedProperties@



  1. Create:

application-dev.properties

application-prod.properties



  1. run:



mvn clean spring-boot:run -Pprod

//or

mvn clean spring-boot:run -Dspring-boot.run.profiles=dev

Run minikube with podman on Fedora

After install minikube as described in the documentation , set rootless property to true to use Podman without sudo: minikube config set roo...