How to Configure Spring Profile in Tomcat ? - onlinetutorialspoint

PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
JAVAEXCEPTIONSCOLLECTIONSSWINGJDBC
EXCEPTIONS
COLLECTIONS
SWING
JDBC
JAVA 8
SPRING
SPRING BOOT
HIBERNATE
PYTHON
PHP
JQUERY
PROGRAMMINGJava ExamplesC Examples
Java Examples
C Examples
C Tutorials
aws
There are multiple ways to configure Spring profile in tomcat. Let’s see here.
If you are running the application in your local, you can set the active profile using -Dspring-boot.run.profiles=test/dev/prod property as a parameter to your maven or Gradle run command.
Example:
#maven 
mvnw spring-boot:run -Dspring-boot.run.profiles=dev
#Gradle
gradlew bootRun -Dspring-boot.run.profiles=dev

To configure the same in Eclipse tomcat, select Run -> Run Configurations and choose your Tomcat run configuration. Click the Arguments tab and add -Dspring.profiles.active=dev at the end of VM arguments.
Again you can have multiple options here to configure Spring profile in tomcat in the external config, the most prominent way is to set the profile in catalina.properties.
Add profile in catalina.properties file by omitting -D
spring.profiles.active=dev
./startup.sh

ed JARs during scanning can improve startup time and JSP compilation time.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.4.RELEASE)

2020-05-05 08:02:13.992  INFO 192322 --- [           main] c.s.SampleApplication             : Starting SampleApplication v0.0.1-SNAPSHOT on localhost.localdomain with PID 192322 (/opt/cgoka/tomcat/webapps/sample_application/WEB-INF/classes started by root in /root)
2020-05-05 08:02:13.996  INFO 192322 --- [           main] c.s.SampleApplication             : The following profiles are active: dev

Now you can see the log message “The following profiles are active: dev” like above.
How to implement Spring Boot Profiles
Happy Learning 🙂

Spring Boot Environment Properties reading based on activeprofile
How to enable Swagger in Spring Boot Application
How to set Spring Boot SetTimeZone
External Apache ActiveMQ Spring Boot Example
How to use Spring Boot Random Port
Spring Boot MongoDB + Spring Data Example
Spring Boot Basic Authentication Example
How to Create own Spring Boot Error Page
How To Change Spring Boot Context Path
Step By Step Spring Boot Docker Deployment Example
SSL Spring Boot HTTPs Enabling Example
How to set Spring Boot Tomcat session timeout
How to change Spring Boot Tomcat Port Number
Spring Boot How to change the Tomcat to Jetty Server
Spring Boot JNDI Configuration – External Tomcat

Spring Boot Environment Properties reading based on activeprofile
How to enable Swagger in Spring Boot Application
How to set Spring Boot SetTimeZone
External Apache ActiveMQ Spring Boot Example
How to use Spring Boot Random Port
Spring Boot MongoDB + Spring Data Example
Spring Boot Basic Authentication Example
How to Create own Spring Boot Error Page
How To Change Spring Boot Context Path
Step By Step Spring Boot Docker Deployment Example
SSL Spring Boot HTTPs Enabling Example
How to set Spring Boot Tomcat session timeout
How to change Spring Boot Tomcat Port Number
Spring Boot How to change the Tomcat to Jetty Server
Spring Boot JNDI Configuration – External Tomcat






Adam
January 22, 2021 at 10:04 pm - Reply 

how to set profile only for specific .war when using external tomcat?
for example i have two apps and one of them is using profile “dev” and second app is using profile “prod”










Adam
January 22, 2021 at 10:04 pm - Reply 

how to set profile only for specific .war when using external tomcat?
for example i have two apps and one of them is using profile “dev” and second app is using profile “prod”




how to set profile only for specific .war when using external tomcat?
for example i have two apps and one of them is using profile “dev” and second app is using profile “prod”
 


Δ
 Spring Boot – Hello World
 Spring Boot – MVC Example
 Spring Boot- Change Context Path
 Spring Boot – Change Tomcat Port Number
 Spring Boot – Change Tomcat to Jetty Server
 Spring Boot – Tomcat session timeout
 Spring Boot – Enable Random Port
 Spring Boot – Properties File
 Spring Boot – Beans Lazy Loading
 Spring Boot – Set Favicon image
 Spring Boot – Set Custom Banner
 Spring Boot – Set Application TimeZone
 Spring Boot – Send Mail
 Spring Boot – FileUpload Ajax
 Spring Boot – Actuator
 Spring Boot – Actuator Database Health Check
 Spring Boot – Swagger
 Spring Boot – Enable CORS
 Spring Boot – External Apache ActiveMQ Setup
 Spring Boot – Inmemory Apache ActiveMq
 Spring Boot – Scheduler Job
 Spring Boot – Exception Handling
 Spring Boot – Hibernate CRUD
 Spring Boot – JPA Integration CRUD
 Spring Boot – JPA DataRest CRUD
 Spring Boot – JdbcTemplate CRUD
 Spring Boot – Multiple Data Sources Config
 Spring Boot – JNDI Configuration
 Spring Boot – H2 Database CRUD
 Spring Boot – MongoDB CRUD
 Spring Boot – Redis Data CRUD
 Spring Boot – MVC Login Form Validation
 Spring Boot – Custom Error Pages
 Spring Boot – iText PDF
 Spring Boot – Enable SSL (HTTPs)
 Spring Boot – Basic Authentication
 Spring Boot – In Memory Basic Authentication
 Spring Boot – Security MySQL Database Integration
 Spring Boot – Redis Cache – Redis Server
 Spring Boot – Hazelcast Cache
 Spring Boot – EhCache
 Spring Boot – Kafka Producer
 Spring Boot – Kafka Consumer
 Spring Boot – Kafka JSON Message to Kafka Topic
 Spring Boot – RabbitMQ Publisher
 Spring Boot – RabbitMQ Consumer
 Spring Boot – SOAP Consumer
 Spring Boot – Soap WebServices
 Spring Boot – Batch Csv to Database
 Spring Boot – Eureka Server
 Spring Boot – MockMvc JUnit
 Spring Boot – Docker Deployment