Issue
I have these entries in application.properties file in my Spring boot application.
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto =none
#jwt
app.jwt.secret=RandomSecretKey
#1 day
app.jwt.expiration-in-ms=86400000
app.jwt.token.prefix=Bearer
app.jwt.header.string=Authorization
I need to set these properties at application start using an XML settings file, so that I can change them according to database type in use. Please note XML settings file is the only way I can do this since I am converting the final jar file to an exe file using jar2exe. I have the code to read the XML and get these values but can't figure out how to assign these values.
Solution
Create a LocalSessionFactoryBean in the code yourself as opposed to relying on Spring to create on for you. Doing so would allow you to send in the properties you want. You can see an example here: What's the benefit of Spring xml ioc over Java instantiation?
Answered By - LiveNLearn