Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello everyone, please I can't get SpringMVC project to create a table in MySql database. My entity class is below.
public class Customer {

	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	private String firstName;
	private String lastName;
	private String email;

This is my file.


#Setting the contextPath for the application

#DataSource configuration(hikaricp)
spring.datasource.url = jdbc:mysql:///javafullstack
spring.datasource.username = root
spring.datasource.password = root

#JPA -hibernate properties

My is under src/main/resources and my jsp files are under src/main/WEB-INF/pages, please what I'm I missing ? Thanks for any help.

What I have tried:

The code complied without any error but the table is not created in the database.

1 solution

I've resolved this issue, created a package for the main class where the method is and I created my other packages on the same level as the package where the main class was instead of creating them directly as sub-packages under that package that created. Apparently was happens is that @ComponentScan detects packages the are sub-packages of the main class to create/register the Spring managed components and since my other packages (services, model, dao, restcontroller) were not directly under the main class's package, Spring couldn't detect them, that's why the table wasn't created in the DB. I hope this might help someone someday.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900