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

How to deploy Podman images to OpenShift Container Platform (CRC on localhost)

I have a microservice on localhost and I want to deploy its Podman image on OCP, which I am running using CRC on localhost.       1. Get the...