Spring boot datasource specific properties for embedded jetty server - spring-boot

I have spring boot application and it's basically a gradle project, so, I have below dependency added in my gradle file:
org.springframework.boot:spring-boot-gradle-plugin:1.5.1.RELEASE
Application gets deployed in embedded jetty server. I have following set of properties in application.properties for db connection polling:
spring.datasource.driver-class-name
spring.datasource.max-active
spring.datasource.max-idle
spring.datasource.min-idle
spring.datasource.validation-query
spring.datasource.name
I was referring to below two links:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.4-Configuration-Changelog
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.5-Configuration-Changelog
I came to know that some of the datasource properties which used in application.properties file in my application are removed starting sprint boot version 1.4 but issue they haven't mentioned what are the new properties to use. Like for tomcat server they have provided all set of properties but not for jetty server. I am facing some db related errors like 'too many connections' after my application run for sometime, my assumption is that datasource props I am currently using are not correct and should be replaced with correct values, but unfortunately I am unable to find correct property names.

Jetty doesn't have its own Pooling DataSource implementation. You can include HikariCP in your project and customise using the spring.datasource.hikari.* properties. With each property matching the bean properties that can be set on Hikari's datasource implementation.

Related

setting liquibase.changelogSchemaName property in spring boot

I am facing issue while setting the changelogSchemaName for liquibase in spring boot.
I am setting it like below -
spring.datasource.datsourcename.liquibase.changelogSchemaName =
But it seems spring boot is not reading this property.
How can this property be set. My problem is I want to use separate schema for changelog tables which i s different from actual schema.
You can use
spring.liquibase.liquibase-schema=
in your application.properties file for the springboot app.

Get NoInitialContext Spring Boot 2.0.x Embedded Tomcat Resource and DataSource Configuration Using JavaConfig

Following other links I have tried all configurations including enabling jndi of embedded tomcat container. (A very good detailed like is: https://www.roytuts.com/spring-boot-jndi-datasource/) But the problem is that the DataSource is looked up against JNDI and I get follwoing exception:
Please note that From Spring 2.0.x Embedded configuration classes have changed.
Get:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
As for the question of JNDI lookup in Embedded tomcat is rare use case I am trying to simulate and reproduce a Database Connection Pooling Error in production and for that I have to use JavaConfig settings for Resource and DataSource both.

Grails - Customizing datasource configuration from a spring bean

I have a legacy grails app running grails v3.2.9. We are currently using properties files for setting the dataSource configuration.
We have an internal system that stores our configurations that is loaded as a spring bean. I need to use this to hook it into our configuration system for compliance reasons. Is there any way to configure the dataSource from these at startup?

Defining Database dynamically in spring boot maven based war application

My Spring boot application won't know the database to be connected in prior, once before application deployment, the user will select the database to be connected, and places the jar in the server webinf(or probably some other repository path), and changes the externalized properties file, so that application connects to the database, I was trying giving the database dependency scope as provided, but getting class not found. What is the preferred approach for solving the issue?
You can run your Spring Boot bootJar like this:
java -cp your-jdbc-driver.jar -jar your-boot-jar.jar --spring.datasource.url=your:jdbc:url

Difference between a Spring datasource and a Tomcat datasource?

What is the difference between a Spring datasource and Tomcat datasource? Any pro's / con's? Is there a favored choice?
When using a Tomcat datasource you have to drop the JDBC driver JAR file(s) in Tomcat's classpath (the Tomcat/lib). This is sometimes not affordable/possible, for example when it concerns 3rd party hosting with zero server admin rights. When using a Spring managed datasource, it's sufficient to just drop the JDBC driver JAR file(s) in webapp's classpath (the Webapp/WEB-INF/lib). Plus, I'd imagine that you've in Spring the additional benefit that you don't need to grab the DataSource manually. Also, you have the freedom of choosing a specific connection pool. Also, Tomcat ships with DBCP builtin as default connection pool which is not the best choice per se. With Spring, you could for example choose BoneCP above DBCP without the need to fiddle with Tomcat default configuration/classpath.
If you have a datasource in the Spring config, you associate it with a Tomcat datasource when you are in a web application. You can associate it with something else, for example Spring DriverManagerDataSource when you run unit tests.

Resources