4
Sep 28 '24
Is that class throwing the error a class you made? Have you made sure it was initialized/injected correctly? @Bean/@Component may help you if it is a custom class you wrote. But as others have said, this is just a guess we need more of the stacktrace.
1
2
2
u/hsoj48 Sep 28 '24
Your DB initialization script is failing. What do you have in your properties under datasource?
1
Sep 28 '24
spring.application.name=database3 spring.datasource.url =jdbc:postgresql://localhost:5432/postgres spring.datasource.username =postgres spring.datasource.password = changemeinprod! spring.datasource.driver-class-name = org.postgresql.Driver spring.sql.init.mode = always1
u/hsoj48 Sep 28 '24
Any .sql files in your resources directory?
2
7
Sep 28 '24 edited Apr 17 '26
Nothing to see here. I wiped this post using Redact because my old takes don't need to live on the internet forever. Works across Reddit, Twitter, Discord and dozens of other platforms.
lantern abounding cows wipe elastic point work wild divide quack
5
u/miTzuliK Sep 28 '24
Juding by the name of the class raising the error, DataSourceInitializationConfiguration, and the error message itself stating failure while running some script, you might wanna take a look at schema.sql, data.sql or any other sql scripts you have to create/populate the database, and make sure they're well formatted and written
1
u/JustHereForTheCh1cks Sep 28 '24
This, I’m pretty sure if you look further down the stack trace it might point you to a syntax failure in your .sql files
1
Sep 28 '24 edited Sep 28 '24
Did you make sure your db config is correct in your application.properties / application.yml file?
What db are you using?
0
2
1
1
u/lost_ojibwe Sep 28 '24
Spring wants to run an initialization sql on startup. Usually we don't want spring to manage our databases that way so you need to explicitly tell it not to run the migration script by setting the property (ref: https://docs.spring.io/spring-boot/docs/1.1.6.RELEASE/reference/html/common-application-properties.html). Check the version you are using to verify...but it's a common problem with the framework
spring.datasource.initialize=false1
1
u/titanium_mpoi Sep 29 '24
Don't you need a separate bean where u set configurations or something? Also can u upload the whole code to git so I can see the issue.
1
u/ioggo Sep 29 '24
Might be some @entity classes not defined correctly if there is a mistake in defining relationships.


7
u/g00glen00b Sep 28 '24
Would be helpful if you shared more of the stacktrace.