Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Error creating bean with name 'entityManagerFactory' defined in br.com.kodeweave.conf.JPAConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Gente na hora que tento subir o sevidor da o seguinte erro: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in br.com.kodeweave.conf.JPAConfiguration: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Poderiam me ajudar? Preciso disso com urgencia e não sei o por que está dando errado :(

` package br.com.kodeweave.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.JpaDialect; 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 factoryBean = 
        new LocalContainerEntityManagerFactoryBean();

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();

    factoryBean.setJpaVendorAdapter(vendorAdapter);

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setUsername("root");
    dataSource.setPassword("test"); // modifique para a senha do seu banco
    dataSource.setUrl("jdbc:mysql://localhost:3306/kodeweave1");
    dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
    factoryBean.setDataSource(dataSource);

    Properties props = new Properties();
    props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
    props.setProperty("hibernate.show_sql", "true");
    props.setProperty("hibernate.hbm2ddl.auto", "update");
    factoryBean.setJpaProperties(props);

    factoryBean.setPackagesToScan("br.com.kodeweave.models");

    return factoryBean;

}

@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
    return new JpaTransactionManager(emf);
}

}

3 respostas

Boa tarde, qual a versão do Java ?

Dei javac --version ta no 10.0.2

E no java -version deu isso:

openjdk 10.0.2 2018-07-17 OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4) OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

solução!

Oie, então. Mudei a versão do Java pro 1.8 e agora está subindo certinho o servidor. Muito Obrigado :)