Ao criar o projeto e iniciar o tomcat dá erro. Está criado o banco no mysql mas, não tem as tabelas. A conexão com o banco foi alterada para informar a senha.
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUsername("root");
dataSource.setPassword("root");
dataSource.setUrl("jdbc:mysql://localhost:3306/casadocodigo?autoReconnect=true&useSSL=false");
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
return dataSource;
}
Tentei rodar o projeto no eclipse e no intellij e ambos estão dando o mesmo erro.
[2018-09-27 11:57:40,304] Artifact casadocodigo:war: Artifact is deployed successfully
[2018-09-27 11:57:40,305] Artifact casadocodigo:war: Deploy took 20.630 milliseconds
Erro genérico acontecendo
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:430)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:438)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:261)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
at br.com.casadocodigo.loja.daos.ProdutoDAO$$EnhancerBySpringCGLIB$$7c2b10ec.listar(<generated>)
at br.com.casadocodigo.loja.controllers.HomeController.index(HomeController.java:32)
at br.com.casadocodigo.loja.controllers.HomeController$$FastClassBySpringCGLIB$$eb88f233.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)