i’m developing a Spring project as an exercise.
My project correctly connects to the DB, but it doesn’t autogenerate the tables. So, for now i had to create them myself. I thought the problem was i got something wrong with my .yml file, but i think i figured it’s not the case.
The reason I say this is because i tried to implement a Mapper using the MapStruct dependency, and every time i run the project, no matter what i did, it would give me an error on the @Autowired tag, because he could not find the bean. I fixed this by adding a @ComponentScan in my Main class, so i found out that something was not working with the scanning.
But now, even if I “fixed” that problem, by looking online i found out that if Spring doesnt’ correctly detect the package with the entities, it would obviously not create the tables in my db.
Now i need help actually fixing this problem. It’s so strange because i simply created a project with Spring initializer, the Main class is above all the packages as it should be, since i read that this is the main reason of this kind of problems (in fact i can use my Controller correctly with postman, so my project scans some packages but other… don’t?). So maybe i’m missing something.
Here’s my .yml file.
spring:
application:
name: esercitazione
jmx:
default-domain: it.prenota.ticket
jpa:
database: POSTGRESQL
show-sql: true
properties:
hibernate:
ddl-auto: update
default_schema: public
jdbc:
lob:
non_contextual_creation: true
datasource:
platform: postgres
url: jdbc:postgresql://localhost:5432/tutordb
username: postgres
password: indra
driverClassName: org.postgresql.Driver
hikari:
maximumPoolSize: 5
minimumIdle: 1
And here’s the hierarchy of my packages:
Project
I don’t know if it’s worth nothing, but i first started using my project with Eclipse, then i switched to IntelliJ.
boh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.