Olá, implementei minha JPAConfiguration mas ao subir o servidor da erro 500 ao conectar com o banco de dados "javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection"
minha classe
package br.com.notus.conf;
import java.util.Properties;
import javax.persistence.EntityManagerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
public class JPAConfiguration {
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean factorBean = new LocalContainerEntityManagerFactoryBean();
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
factorBean.setJpaVendorAdapter(vendorAdapter);
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUsername("root");
dataSource.setPassword("admin");
dataSource.setUrl("jdbc:msysql://localhost:3007/notus");
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
factorBean.setDataSource(dataSource);
Properties prop = new Properties();
prop.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
prop.setProperty("hibernate.show_sql", "true");
prop.setProperty("hibernate.hbm2ddl.auto", "update");
factorBean.setJpaProperties(prop);
factorBean.setPackagesToScan("br.com.notus.models");
return factorBean;
}
@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}
}
OBS: A porta quando eu criei o banco de dados utilizei a 3007 mesmo, pois a 3006 já estava sendo utilizada por outro projeto meu.