Reputation: 2783
It`s possible to use tomcat datasource with springboot in develop mode?
I want to configure my project to use tomcat datasource so, when I create one .war and deploy at my tomcat client that have datasource configured works fine
but how can I use this with mvn spring-boot:run?
Upvotes: 2
Views: 1027
Reputation: 78579
It seems that what you want is to use different configurations for different environments.
What you need is taking advantage of Spring Profiles. By setting the variable spring.profiles.active
you can define your current environment settings.
For example, in production, when you run your application, in your JVM settings you set a:
java -Dspring.profiles.active=production ...
But when you're developing your application, in your IDE you set the settings to
spring.profiles.active=development
I typically do it using Spring Boot configuration using YAML, and then I define environment specific settings by defining a multi-profile document:
spring:
profiles: development,default
datasource:
url: "jdbc:postgresql://localhost:1543/jedis"
username: "luke"
password: "sk1walk3r!"
driver-class-name: "org.postgresql.Driver"
spring:
profiles: production
datasource:
jndi-name=java:jboss/datasources/jedis
That way you can easily change the settings you use while working on development or debugging in your IDE, etc.
There is probably a way to do it using properties files as well, but I wouldn't know since I always use YAML.
Upvotes: 1