Ainda não tem acesso? Estude com a gente! Matricule-se
Ainda não tem acesso? Estude com a gente! Matricule-se

Erro 404

Error

Multiple annotations found at this line:

- The method getBuild() is undefined for the 
 type String

Erro aponta nessa linha

16 respostas

Esse warning gerado pelo Eclipse é porque ele não reconhece esse comando que é especifico do Spring e marca ele como um erro. Todo link que fizer dessa forma vai constar como erro no Eclipse, mas pode ficar tranquilo que não deveria influenciar no funcionamento do seu projeto.

Sobre as configurações.

TomCat 8.5 MySql 8.0 Java 8 Configuração no maven.

mysql mysql-connector-java 8.0.13

///////////////////////////// Configuração no Dialect props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL8Dialect"); props.setProperty("hibernate.show_sql", "true"); props.setProperty("hibernate.hbm2ddl.auto", "create-drop");

GRAVE: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getEntityManagerFactory' defined in class path resource [br/com/caelum/JpaConfigurator.class]: Invocation of init method failed; nested exception is org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.dialect.MySQL8Dialect] as strategy [org.hibernate.dialect.Dialect] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)

Da uma ajuda ai mano toh quebrando a cabeça nesse erro.

Mostra o método ou a classe completa aqui para gente.

@Configuration @EnableTransactionManagement public class JpaConfigurator {

@Bean
public DataSource getDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();

    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl("jdbc:mysql://localhost/projeto_jpa");
    dataSource.setUsername("root");
    dataSource.setPassword("1234");

    return dataSource;
}

@Bean
public LocalContainerEntityManagerFactoryBean getEntityManagerFactory(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();

    entityManagerFactory.setPackagesToScan("br.com.caelum");
    entityManagerFactory.setDataSource(dataSource);

    entityManagerFactory
            .setJpaVendorAdapter(new HibernateJpaVendorAdapter());

    Properties props = new Properties();

    props.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL8Dialect");
    props.setProperty("hibernate.show_sql", "true");
    props.setProperty("hibernate.hbm2ddl.auto", "create-drop");

    entityManagerFactory.setJpaProperties(props);
    return entityManagerFactory;
}

@Bean
public JpaTransactionManager getTransactionManager(EntityManagerFactory emf) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(emf);

    return transactionManager;
}

}

4.0.0 br.com.caelum projeto-jpa-2 war 1.0-SNAPSHOT Projeto JPA 2 http://maven.apache.org <spring.version>4.1.6.RELEASE</spring.version>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.2.1.Final</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
        <scope>runtime</scope>
    </dependency>


    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>

    <!-- <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> 
        <version>2.6.9</version> </dependency> -->

    <!-- Hibernate EHCache API -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>4.3.5.Final</version>
    </dependency>
    <!-- EHCache uses slf4j for logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
    </dependency>

    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.5.Final</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
    </dependency>
mysql mysql-connector-java 8.0.13 org.springframework spring-orm ${spring.version} projeto-jpa-2 org.apache.maven.plugins maven-compiler-plugin 3.3 1.7 1.7

Pelo erro parece quer você não está usando o MySQL Connector na versão 8 (não está localizando):

Unable to resolve name [org.hibernate.dialect.MySQL8Dialect] as strategy [org.hibernate.dialect.Dialect] at

Posta pom.xml completo e o stack de erro completo também, por favor

<modelVersion>4.0.0</modelVersion>
    <groupId>br.com.caelum</groupId>
    <artifactId>projeto-jpa-2</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Projeto JPA 2</name>
    <url>http://maven.apache.org</url>
    <properties>
        <spring.version>4.1.6.RELEASE</spring.version>
    </properties>
    <dependencies>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.2.1.Final</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
            <scope>runtime</scope>
        </dependency>
javax.validation validation-api 1.1.0.Final
    <!-- <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> 
        <version>2.6.9</version> </dependency> -->

    <!-- Hibernate EHCache API -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>4.3.5.Final</version>
    </dependency>
    <!-- EHCache uses slf4j for logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
    </dependency>

    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.3.5.Final</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
    </dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.13</version>
</dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>projeto-jpa-2</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

OLa alguma ajuda toh nesse erro faz uma semana, j[a tentei outras versões do mysql-connector no maven.

Alguem pode me informar as qual versão do MySql é ultilizado no curso ? o tomcat ultilizo esse TomCat 8.5

Oi Thales

Tenta utilizar o MySQL 5, deve resolver.

Se você quiser usar o MySQL 8 vai ter que atualizar as dependências do Hibernate pelo menos para a 5.3.1.Final (ou mais nova).

<dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.4.8.Final</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-ehcache</artifactId>
            <version>4.3.5.Final</version>
        </dependency>

Erro aponta outro agora GRAVE: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getEntityManagerFactory' defined in class path resource [br/com/caelum/JpaConfigurator.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'getEntityManagerFactory' threw exception; nested exception is java.lang.IllegalStateException: Failed to determine Hibernate PersistenceProvider