J'essaie d'utiliser la source de données tomcat groupée avec démarrage au printemps uniquement en spécifiant les propriétés dans le fichier application.yml comme suit:Lors de l'utilisation de la source de données tomcat pooled dans springboot, je reçois aucun bean qualifiant de type 'javax.sql.DataSource'
spring:
data:
jpa:
repositories:
enabled: true
datasource:
tomcat:
max-active: 50
max-wait: 10000
username: postgres
password: root
url: jdbc:postgresql://localhost:5432/proj
driver-class-name: org.postgresql.Driver
Je reçois
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
Je ne comprends pas pourquoi springboot tente de créer une source de données intégrée. Est-ce le comportement attendu pour une source de données poolée?
J'ai vu sur certains forums que la dépendance de spring-jdbc pouvait causer ce problème, donc j'ai exclu toutes les dépendances de spring-jdbc. Non, je me
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory
.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
fichier POM
http://maven.apache.org/xsd/maven-4.0.0.xsd "> 4.0.0
<groupId>com.yyyy.xxxx</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>xxxx</name>
<description>xxxx project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<jsoup.version>1.10.3</jsoup.version>
<log4j.version>1.2.17</log4j.version>
</properties>
<organization>
<name>SA Technologies</name>
<url>www.satechnologies.com</url>
</organization>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>${jsoup.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.5.4-Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>de.jpdigital</groupId>
<artifactId>hibernate5-ddl-maven-plugin</artifactId>
<version>1.0.1-hibernate-5.1.2.Final</version>
<configuration>
<dialects>
<param>POSTGRESQL9</param>
<param>SQLSERVER2012</param>
</dialects>
<packages>
<param>com.yyyy.xxxx.model</param>
</packages>
<outputDirectory>${project.basedir}/docs/sql</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>gen-ddl</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
@EnableJpaRepositories(basePackages = { "com.yyyy.xxxx.persistence.repositories" })
@EnableTransactionManagement
@EntityScan(basePackages = { "com.yyyy.xxxx.persistence.model" })
@Configuration
public class PersistenceConfig {
}
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LoggingInterceptor());
}
}
@SpringBootApplication(scanBasePackages = { "com.yyyy.xxxx" })
public class XxxxApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(XxxxApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(XxxxApplication.class, args);
}
}
Tout le monde peut aider s'il vous plaît?
Pouvez-vous télécharger votre fichier de configuration et POM? – Afridi
Ajouter cette dépendance et laissez-moi savoir: \t \t \t org.springframework.boot \t \t \t printemps-boot-démarreur-jdbc \t \t –
Afridi
Je l'ai ajouté, mais il me reste l'exception: Causé par: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties $ DataSourceBeanCreationException: Impossible de déterminer la classe de pilote de base de données intégrée pour le type de base de données NONE. Si vous voulez une base de données intégrée, veuillez en mettre une sur le classpath. Si vous avez des paramètres de base de données à charger à partir d'un profil particulier, vous devrez peut-être l'activer (les profils "local" sont actuellement actifs). J'ai ajouté un profil local et l'ai activé par défaut. Le texte d'exception me trompe ... – Sofiane