maven SpringBoot迁移,无法配置数据源

lmvvr0a8  于 2023-01-12  发布在  Maven
关注(0)|答案(1)|浏览(151)

我正在尝试将一个SpringBoot应用程序从版本2.1.5.RELEASE迁移到2.7.7。该项目使用Maven和Java 8。
在pom.xml中进行更改后,应用程序无法启动:

Description:

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

下面是运行良好的旧pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.demo</groupId>
  <artifactId>demo</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.1.5.RELEASE</version>
  </parent>

  <properties>
      <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
      <java.version>1.8</java.version>
      <demo.profiles.active>local</demo.profiles.active>
      <demo.build.skip.frontend>true</demo.build.skip.frontend>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <timestamp>${maven.build.timestamp}</timestamp>
      <maven.build.timestamp.format>yyyy-MM-dd HH:mm Z</maven.build.timestamp.format>
      <commons-lang3.version>3.3.2</commons-lang3.version>
      <jacoco-maven-plugin.version>0.7.7.201606060606</jacoco-maven-plugin.version>
      <aws-java-sdk.version>1.12.60</aws-java-sdk.version>
      <spring-integration-aws.version>2.2.0.RELEASE</spring-integration-aws.version>
      <jjwt.version>0.7.0</jjwt.version>
      <geda.core.version>3.1.2</geda.core.version>
      <springfox-swagger2.version>2.7.0</springfox-swagger2.version>
      <frontend-maven-plugin.nodeVersion>v6.9.4</frontend-maven-plugin.nodeVersion>
      <caffeine.version>2.8.1</caffeine.version>
  </properties>
  <dependencies>
     <dependency>    
       <groupId>org.jolokia</groupId>
       <artifactId>jolokia-core</artifactId>
     </dependency>
     <dependency>
       <groupId>com.newrelic.agent.java</groupId>
       <artifactId>newrelic-api</artifactId>
       <version>3.42.0</version>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
     </dependency>
     <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-file</artifactId>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-integration</artifactId>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
     </dependency>
     <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-aws</artifactId>
         <version>${spring-integration-aws.version}</version>
     </dependency>
     <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>${commons-lang3.version}</version>
     </dependency>
     <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
     </dependency>
     <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-envers</artifactId>
     </dependency>

     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
     </dependency>
     <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>${jjwt.version}</version>
     </dependency>

     <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-core</artifactId>
        <version>${aws-java-sdk.version}</version>
    </dependency>
    <dependency>
        <artifactId>aws-java-sdk-s3</artifactId>
        <groupId>com.amazonaws</groupId>
        <version>${aws-java-sdk.version}</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-ses</artifactId>
        <version>${aws-java-sdk.version}</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-sqs</artifactId>
        <version>${aws-java-sdk.version}</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-cognitoidp</artifactId>
        <version>${aws-java-sdk.version}</version>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>${aws-java-sdk.version}</version>
    </dependency>

    <dependency>
        <groupId>com.inspire-software.lib.dto.geda</groupId>
        <artifactId>geda.core</artifactId>
        <version>${geda.core.version}</version>
        <exclusions>
            <exclusion>
                <artifactId>javassist</artifactId>
                <groupId>javassist</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>
        
    <dependency>
        <groupId>org.modelmapper</groupId>
        <artifactId>modelmapper</artifactId>
        <version>1.1.0</version>
    </dependency>

    <dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
    </dependency>
        
    <dependency>
        <groupId>com.github.ulisesbocchio</groupId>
        <artifactId>jasypt-spring-boot-starter</artifactId>
        <version>2.1.1</version>
    </dependency>
        
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>${springfox-swagger2.version}</version>
    </dependency>

    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>${springfox-swagger2.version}</version>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.16</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.statemaczze</groupId>
        <artifactId>spring-statemaczze-core</artifactId>
        <version>2.1.3.RELEASE</version>
    </dependency>

    <dependency>    
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.pdfbox</groupId>
        <artifactId>pdfbox</artifactId>
        <version>2.0.7</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-mail</artifactId>
    </dependency>

    <dependency>         
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.3</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20170516</version>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.196</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
    </dependency>    
</dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/conf</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/conf/${demo.profiles.active}/</directory>
                                    <includes>
                                        <include>**/*.properties</include>
                                        <include>**/*.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-resources2</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/conf/${demo.profiles.include1}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/conf/${demo.profiles.include1}/</directory>
                                    <includes>
                                        <include>**/*.properties</include>
                                        <include>**/*.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-resources3</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/conf/${demo.profiles.include2}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/conf/${demo.profiles.include2}/</directory>
                                    <includes>
                                        <include>**/*.properties</include>
                                        <include>**/*.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>static/**</include>
                    <include>db/**</include>
                    <include>testdata/**</include>
                    <include>bitsensor.properties</include>
                    <include>templates/**</include>
                </includes>
                <excludes>
                    <exclude>conf/*</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

    <profiles>
        <profile>
            <id>local</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <demo.profiles.active>local</demo.profiles.active>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                </dependency>
            </dependencies>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources</directory>
                        <includes>
                            <include>conf/local/*</include>
                            <include>logback-spring.xml</include>
                        </includes>
                        <filtering>true</filtering>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>1.3</version>
                        <executions>
                            <execution>
                                <id>npm run ng -- build --progress=false</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <arguments>run prod</arguments>
                                </configuration>
                            </execution>
                        </executions>
                        <configuration>
                            <nodeVersion>${frontend-maven-plugin.nodeVersion}</nodeVersion>
                            <workingDirectory>src/main/webapp</workingDirectory>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

以下只是我在pom.xml中所做的更改

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.7</version>
    </parent>
    <properties>
        <spring-cloud.version>2021.0.3</spring-cloud.version>
...

新增

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
   <groupId>org.springframework.cloud</groupId> 
   <artifactId>spring-cloud-starter-oauth2</artifactId>
   <version>2.2.5.RELEASE</version>
</dependency>

更改了Flyway依赖性,因为我们使用的是Mysql 5.6

<dependency>
  <groupId>org.flywaydb</groupId>
  <artifactId>flyway-core</artifactId>
  <version>5.2.4</version>
</dependency>

将Swagger替换为SpringDoc

<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-ui</artifactId>
  <version>1.6.6</version>
</dependency>
<dependency>
  <groupId>io.swagger.core.v3</groupId>
  <artifactId>swagger-annotations</artifactId>
  <version>2.1.10</version>
</dependency>

来自db.properties文件:

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/prod?useSSL=false&serverTimezone=UTC
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=password

application.properties:

spring.profiles.active=local
spring.config.location=conf/local

从主类:

@SpringBootApplication
@EnableTransactionManagement
@EnableAuthorizedFeignClients
@EnableEncryptableProperties
@PropertySource({"classpath:${spring.config.location:conf/local}/application.properties"})
@PropertySource({"classpath:${spring.config.location:conf/local}/poller.properties"})
@EncryptablePropertySource("classpath:${spring.config.location:conf/local}/db.properties")
@PropertySource({"classpath:${spring.config.location:conf/local}/s3.properties"})
@PropertySource({"classpath:${spring.config.location:conf/local}/mail.properties"})
@EncryptablePropertySource({"classpath:${spring.config.location:conf/local}/security.properties"})
@PropertySource({"classpath:${spring.config.location:conf/local}/afm.properties"})
@PropertySource({"classpath:${spring.config.location:conf/local}/pdf.properties"})
@PropertySource({"classpath:${spring.config.location:conf/local}/authy.properties"})
@PropertySource({"classpath:${spring.config.location:conf/local}/sqs.properties"})
public class Application extends SpringBootServletInitializer {

应用程序构建无误,并且在目标文件夹中包含正确的属性文件以及以下两个文件夹中的正确数据:target/conf/和target/classes/conf/local/。但是,当启动应用程序时,我看到没有一个local被设置为活动配置文件,并且从错误中我看到没有从属性文件中选择数据库URL。
以下是启动应用程序时的输出

2023-01-10 14:14:18 [main] INFO  {com.demo.Application.logStarting:55} - Starting Application using Java 1.8.0_275 on MacBook-Pro.local with PID 44230 
2023-01-10 14:14:18 [main] INFO  {com.demo.Application.logStartupProfileInfo:631} - No active profile set, falling back to 1 default profile: "default"  
2023-01-10 14:14:22 [main] INFO  {o.s.d.r.c.RepositoryConfigurationDelegate.registerRepositoriesIn:132} - Bootstrapping Spring Data JPA repositories in DEFAULT mode.  
2023-01-10 14:14:23 [main] INFO  {o.s.d.r.c.RepositoryConfigurationDelegate.registerRepositoriesIn:201} - Finished Spring Data repository scanning in 1171 ms. Found 290 JPA repository interfaces.  
2023-01-10 14:14:24 [main] INFO  {o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor.info:292} - No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.  
2023-01-10 14:14:24 [main] INFO  {o.s.i.c.DefaultConfiguringBeanFactoryPostProcessor.info:292} - No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.  
2023-01-10 14:14:24 [main] INFO  {o.s.cloud.context.scope.GenericScope.setSerializationId:283} - BeanFactory id=f01228a5-0c91-3af5-87a8-5de938b7d5f3  
2023-01-10 14:14:24 [main] INFO  {c.u.j.c.EnableEncryptablePropertiesBeanFactoryPostProcessor.postProcessBeanFactory:50} - Post-processing PropertySource instances  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource configurationProperties [org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource] to AOP Proxy  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource servletConfigInitParams [org.springframework.core.env.PropertySource$StubPropertySource] to EncryptablePropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource servletContextInitParams [org.springframework.core.env.PropertySource$StubPropertySource] to EncryptablePropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource systemEnvironment [org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor$OriginAwareSystemEnvironmentPropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource random [org.springframework.boot.env.RandomValuePropertySource] to EncryptablePropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource cachedrandom [org.springframework.cloud.util.random.CachedRandomPropertySource] to EncryptablePropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource springCloudClientHostInfo [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource class path resource [conf/local/sqs.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource class path resource [conf/local/authy.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource class path resource [conf/local/pdf.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource class path resource [conf/local/afm.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource class path resource [conf/local/mail.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource class path resource [conf/local/s3.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource class path resource [conf/local/poller.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.EncryptablePropertySourceConverter.makeEncryptable:39} - Converting PropertySource class path resource [conf/local/application.properties] [org.springframework.core.io.support.ResourcePropertySource] to EncryptableMapPropertySourceWrapper  
2023-01-10 14:14:24 [main] INFO  {c.u.j.f.DefaultLazyPropertyFilter.lambda$null$2:31} - Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter  
2023-01-10 14:14:25 [main] INFO  {c.u.j.r.DefaultLazyPropertyResolver.lambda$null$2:31} - Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver  
2023-01-10 14:14:25 [main] INFO  {c.u.j.d.DefaultLazyPropertyDetector.lambda$null$2:30} - Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector  
2023-01-10 14:14:25 [main] INFO  {o.s.b.w.e.tomcat.TomcatWebServer.initialize:108} - Tomcat initialized with port(s): 8080 (http)  
2023-01-10 14:14:25 [main] INFO  {o.a.catalina.core.StandardService.log:173} - Starting service [Tomcat]  
2023-01-10 14:14:25 [main] INFO  {o.a.catalina.core.StandardEngine.log:173} - Starting Servlet engine: [Apache Tomcat/9.0.70]  
2023-01-10 14:14:25 [main] INFO  {o.a.c.c.C.[Tomcat].[localhost].[/].log:173} - Initializing Spring embedded WebApplicationContext  
2023-01-10 14:14:25 [main] INFO  {o.s.b.w.s.c.ServletWebServerApplicationContext.prepareWebApplicationContext:292} - Root WebApplicationContext: initialization completed in 7169 ms  
2023-01-10 14:14:26 [main] ERROR {o.s.b.w.e.tomcat.TomcatStarter.onStartup:61} - Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourcePoolMetadataMeterBinder' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration$DataSourcePoolMetadataMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourcePoolMetadataMeterBinder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class  
2023-01-10 14:14:26 [main] INFO  {o.a.catalina.core.StandardService.log:173} - Stopping service [Tomcat]  
2023-01-10 14:14:26 [main] WARN  {o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext.refresh:591} - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat  
2023-01-10 14:14:26 [main] INFO  {o.s.b.a.l.ConditionEvaluationReportLoggingListener.logMessage:136} - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.  
2023-01-10 14:14:26 [main] ERROR {o.s.b.d.LoggingFailureAnalysisReporter.report:40} - 

***************************
APPLICATION FAILED TO START
***************************

Description:

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).
  
Disconnected from the target VM, address: '127.0.0.1:63663', transport: 'socket'

Process finished with exit code 1

如果从命令行(-Dspring.profiles.active=local...)提供活动配置文件和连接参数,应用程序将创建一个数据源,并将“local”设置为活动配置文件。

0tdrvxhp

0tdrvxhp1#

问题是jasypt-spring-boot-starter 2.1.1依赖项与SpringBoot 2.7.7不兼容,因此解决方案是将依赖项更新为3.0.5

<dependency>
   <groupId>com.github.ulisesbocchio</groupId>
   <artifactId>jasypt-spring-boot-starter</artifactId>
   <version>3.0.5</version>
</dependency>

相关问题