Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot. How to disable Initialization of JPA Conditionaliy

I'm woundering if it's possible to disable the intialization of JPA Stack competelly.

I some situation my application is executed in enviroment where database is not accessible. Application can survive this on application level. But technically i get some exception on intialization of Data Source.

  1. there musst be some way to disable JPA intialization at all (not needed withoud db. By profile or someting like that.
  2. Or maby at least i can say Connection pool to not connect or somethinglike this.
  3. Other ideas?
like image 734
aholbreich Avatar asked Sep 15 '15 15:09

aholbreich


1 Answers

Yes, you could use profiles for that: one with JPA and another without it. To turn off DataSource/JPA autoconfiguration you need to add spring.autoconfigure.excludes property (with fully-qualified class names) to profile-specific application.properties.

What classes to exclude? I suggest to start from DataSourceAutoConfiguration and if it's not enough try to disable other database-related autoconfiguration classes.

Note that spring.autoconfigure.excludes is a new feature that is avaiable since Spring Boot 1.3.0.M3

like image 123
Slava Semushin Avatar answered Sep 22 '22 17:09

Slava Semushin