Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 376 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spring Boot - Error creating bean with name 'dataSource' defined in class path resource

#21
I am working with spring boot 2.6.0
I tried several answers and they were not enough.
One temporal solution I found was this

@SpringBootApplication(exclude = SqlInitializationAutoConfiguration.class)
Although it lets the server run and the h2-console appear I could not connect to my data.sql file. This was the error I got

Database "mem:testdb" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149

This is the solution I found
(Some have already been)Add these lines to the application.properties file

spring.jpa.show-sql=true
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb
spring.jpa.defer-datasource-initialization=true

Save an re-run the server then try to access the db on the browser again from the h2-console

By default, data.sql scripts are now run before Hibernate is initialized. This aligns the behavior of basic script-based initialization with that of Flyway and Liquibase. If you want to use data.sql to populate a schema created by Hibernate, set spring.jpa.defer-datasource-initialization to true.

spring.jpa.defer-datasource-initialization=true solves the issue
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through