0

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?

1 Answers1

0

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
  • How can I add the database dependency, passing properties is not the issue, dynamically adding the database connectivity jar is the issue am facing. And adding to that, the application is WAR file – Jagadheeswaran Mohan Sep 20 '18 at 12:30
  • So you want to have something like a form so a user can upload a driver jar in your app and then the app add it dynamically to the classpath and create a datasource out of your recently uploaded driver and a URL? – Jorge Valencia Sep 20 '18 at 12:51
  • Something like that, except the user will modify the spring boot properties file. and there will be no UI, he will be adding manually, in webinf – Jagadheeswaran Mohan Sep 20 '18 at 12:56
  • Well in that case sounds like you could let the user upload the driver to the common lib directory of the app server and setup a JNDI datasoure. Take a look [here](https://www.baeldung.com/spring-persistence-jpa-jndi-datasource). – Jorge Valencia Sep 20 '18 at 18:45
  • I tried adding to common lib path, i.e WEB-INF/lib, but once after adding my war file was not getting deployed. – Jagadheeswaran Mohan Sep 20 '18 at 19:00