Application properties: # DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) spring.datasource.driver-class-name = com.mysql.jdbc.Driver spring.datasource.url = jdbc:mysql://localhost:3306/post spring.datasource.sql-script-encoding=UTF-8 spring.datasource.username = ******* spring.datasource.password = ******* # JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration) spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect spring.jpa.hibernate.ddl-auto = create spring.jpa.generate-ddl = true spring.jpa.show-sql = false @EnableAsync @Configuration @SpringBootApplication @EnableTransactionManagement @PropertySource("classpath:application.properties") public class AppConfig extends WebMvcConfigurerAdapter { private static final Logger log = LoggerFactory.getLogger(AppConfig.class); private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {"classpath:/static/", "classpath:/public/","classpath:/templates/"}; @Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return (container -> { ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/error/401/"); ErrorPage error403Page = new ErrorPage(HttpStatus.FORBIDDEN, "/error/403/"); ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error/404/"); ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500/"); ErrorPage registrationException = new ErrorPage(RegistrationException.class, "/error/registrationPageError/"); container.addErrorPages(error401Page, error403Page, error404Page, error500Page); }); } @Bean public EmbeddedServletContainerFactory servletContainer() { Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); connector.setScheme("http"); connector.setSecure(false); connector.setPort(33950); connector.setRedirectPort(33443); TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() { @Override protected void postProcessContext(Context context) { SecurityConstraint securityConstraint = new SecurityConstraint(); securityConstraint.setUserConstraint("CONFIDENTIAL"); SecurityCollection collection = new SecurityCollection(); collection.addPattern("/*"); securityConstraint.addCollection(collection); context.addConstraint(securityConstraint); } }; tomcat.addAdditionalTomcatConnectors(connector); return tomcat; } @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory (DataSource dataSource,JpaVendorAdapter jpaVendorAdapter){ LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean(); entityManagerFactory.setDataSource(dataSource); entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter); entityManagerFactory.setPackagesToScan("ua.kiev.dobrobutZahyst"); return entityManagerFactory; } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { if (!registry.hasMappingForPattern("/**")) { registry.addResourceHandler("/**").addResourceLocations( CLASSPATH_RESOURCE_LOCATIONS); } } @Bean public ShaPasswordEncoder getShaPasswordEncoder(){ return new ShaPasswordEncoder(); } @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(); stringConverter.setSupportedMediaTypes(Arrays.asList(new MediaType("text","plain", Charset.forName("utf-8")))); converters.add(stringConverter); } @Bean public Gson gson(){ final GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter(InputPost.class, new InputPostGsonConverter()); gsonBuilder.registerTypeAdapter(OutputPost.class, new OutputPostGsonConverter()); gsonBuilder.registerTypeAdapter(CorporationPost.class, new CorporationPostGsonConverter()); gsonBuilder.registerTypeAdapter(File.class, new FileGsonConverter()); gsonBuilder.excludeFieldsWithoutExposeAnnotation(); return gsonBuilder.create(); } public static void main(String[] args) throws IOException { SpringApplication.run(AppConfig.class, args); } } 

When the application starts, the construction of the tables is skipped and the application starts. Exception does not pop up. Tell me, please, what to do?

  • first check the connection to the database - Paulo Berezini
  • @PavelBereznichenko everything works fine ... The only problem is that the autogeneration of the tables does not switch. - Nikolay Egorov
  • and what is written in Bina? you can show? - Paulo Berezini
  • @PavelBereznichenko That's all for the database. - Nikolay Egorov
  • @NikolayEgorov, what about annotations over the @EnableJpaRepositories @EnableTransactionManagement configuration class? How is the adapter configured, datasource? Check your question can not, add a minimal example that can be played. - MrFylypenko

0