I am unable to get spring to create tables automatically. I tried every solution I could find regarding the properties and annotation that should be added.
Spring version - 5.2.5.RELEASE
My application properties looks like that:
spring.datasource.url=jdbc:mysql://localhost:3306/ci_test?useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=****
spring.datasource.password=****
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.SQLServerDialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
management.endpoints.web.exposure.include=*
management.endpoint.shutdown.enabled=true
#management.server.port=8090
logging.level.org.springframework=INFO
My Main app:
com.mypackage.autoTester;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.modelmapper.ModelMapper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.core.SpringVersion;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
@EnableConfigurationProperties
@EntityScan(basePackages = {"com.mypackage.autoTester"}) // scan JPA entities
public class AutoTesterApplication {
public static final Logger logger = LogManager.getLogger();
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
public static void main(String[] args) {
SpringApplication.run(AutoTesterApplication.class, args);
}
}
My Entity:
com.mypackage.autoTester.entities;
import lombok.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "testTable")
@Getter
@Setter
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@NoArgsConstructor
public class TestEntity {
@Id
private long id;
}
Is there something wrong with the code above? Am I missing something?
UPDATE:
I tried the solutions below but no help :( Back in the days I used spring boot plugin in eclipse and it worked, I now work with intellij so I am not sure if it is related