Olá pessoal,
Estou com problemas para rodar meu projeto. Estou utilizando o spring-data com H2. Ocorre o erro:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Gostaria de uma ajuda de vcs. O H2 é um banco de teste em memória e nunca precisei realizar configuração alguma. Estou utilizando o STS 4
O Driver do BD está configurado? Poste como você definiu a dependência para vermos.
Olha só @Jothar_Aleksander acabei mudando para a configuração utilizando o mysql:
meu pom.xml ficou assim:
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-web
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- <dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency> -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.17.Final</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.23.2-GA</version>
</dependency>
org.springframework.boot
spring-boot-maven-plugin
Porém ainda esta dando erro:
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
e[2m2019-09-30 20:57:19.806e[0;39m e[31mERRORe[0;39m e[35m3411e[0;39m e[2m—e[0;39m e[2m[ restartedMain]e[0;39m e[36mo.s.boot.SpringApplication e[0;39m e[2m:e[0;39m Application run failed
Minha Aplication.properties
spring.datasource.url=jdbc:mysql://localhost:3306/doutores
spring.datasource.username=root
spring.datasource.password=Certing_1
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.main.allow-bean-definition-overriding=true
Simplesmente a aplicação não roda. Acredito que a configuração do banco esta ok, criei o banco certinho. Ele roda bacana ate aparecer esse WARN:
2019-09-30 21:15:04.573 WARN 3551 — [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
2
Em ambos aparece um alerta sobre o ApplicationContext
. Como está o seu XML de configuração do ApplicationContext
?