Skip to content
Advertisement

Error starting Tomcat context.Exception: org.springframework.beans.factory.BeanCreationException.Message:Error creating bean with name ‘h2Console’ def

I have this simple CRUD Spring HTTP Service (see project structure). I would like to achieve something like dislpay in browser. I made use of Thymeleaf and 2 html files: add-edit-employee.html and list-employees.html.

Initial data comes from an sql table: data.sql & schema.sql. When I run the project I get error:

Log of the errors

2

Pom file

application.properties

EmployeeEntity class

data.sql

schema.sql

If I actually run it with property: spring.datasource.url = jdbc:h2:file:C:/Projects/Workspace IT Academy/M13 Simple Spring HTTP Service/H2DB, instead of jdbc:h2:mem:h2db;DB_CLOSE_DELAY=-1 it will start the app until I try to connect to http://localhost:8080/, then it breaks, and gives me a similar error, telling me that the table does not exist. Ideally, I would like to run it with datasource jdbc:h2:mem:h2db.

I have tried IntelliJ and SpringToolSuit and they give the exact same error. I have seen quite a few other threads about this, but I have not identified the error yet. Could it be that my Jar’s are corrupted? Is it a matter of versions? I have checked and rechecked dependencies, properties..tryed adding dev-tools, and spring-boot-starter-tomcat…but it gives me also errors…There must be something I am missing. Any help would be much appreciated!

Advertisement

Answer

From the stacktrace it is evident that, wehen springboot is starting up , it is trying to execute the schema.sql to create the tables that are necessary for the application and failing due to the syntax error :

I think the issue is the DOUBLE datatype that you provided for salary column in your create table query. As per the H2 documentation it does not take a scale parameter. So , the syntax that you provided in the create table query might be wrong which causes the issue. Try using a numeric instead to confirm.

Try(I haven’t tried executing the query myself) :

H2 Doc.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement