Spring Security 升级到Sping Boot 3时线程“main”中出现异常java.lang.NoSuchMethodError -org.springframework.core.io.support.SpringFactoriesLoader

n7taea2i  于 2023-08-05  发布在  Spring
关注(0)|答案(1)|浏览(129)

编辑:我已经更新了这个问题与Spring Boot 3升级。我正在尝试从2.7.13升级到Sping Boot 3。我最近使用了Spring Security 5.8.4,并进行了Spring Security更改。该应用程序运行于2.7.13和Spring Security 5.8.4。现在我已经换到了Sping Boot 3,我在升级Spring Cloud时遇到了问题。
截至7月10日的更新,我已经清理了依赖项管理,但我的securityConfig.java仍然指向旧的@EnableWebSecurity(5.7.7
所以这里是我的相关版本和pom的片段(7月10日更新):

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.8</version>
    <relativePath/>
    <!-- lookup parent from repository -->
</parent>
//I want to share I have modules that also have a pom in each but they only have spring-booot-starter-web in their dependencies block without specifying version.
<modules>
    <module>module1</module>
    <module>module2</module>
    <module>module3</module>
    <module>app</module>
</modules>

<properties>
    <java.version>17</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <google-cloud-gcp-dependencies.version>4.5.1</google-cloud-gcp-dependencies.version>
    <spring-cloud.version>2022.0.3</spring-cloud.version>
    <jsoup.version>1.10.2</jsoup.version>
    <h2.version>1.4.200</h2.version>
    <apache-common-text>1.10.0</apache-common-text>
    <modelmapper.version>2.3.5</modelmapper.version>
    <com.jayway.jsonpath.version>2.6.0</com.jayway.jsonpath.version>
    <flyway-core.version>9.5.1</flyway-core.version>
    <spring-cloud-function.version>4.0.0</spring-cloud-function.version>
    <postgresql.version>42.4.3</postgresql.version>
    <snakeyaml.version>1.32</snakeyaml.version>
    <properties>

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

        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-oauth2-client</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-config</artifactId>
            </dependency>
            <dependency>
                <groupId>com.google.cloud</groupId>
                <artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-bootstrap</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-configuration-processor</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-core</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-webflux</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-data-jpa</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-stream-test-binder</artifactId>
                <scope>test</scope>
            </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-redis</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-test</artifactId>
                <version>${spring-security.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.thymeleaf</groupId>
                <artifactId>thymeleaf-spring6</artifactId>
                <version>3.1.1.RELEASE</version>
            </dependency>
        </dependencies>

字符串
以下是我的相关Spring依赖项。这里有postgres和h2依赖,还有一个第三方依赖(我已经删除了任何不推荐的方法),但如果没有必要,我不会在这里列出。

igsr9ssn

igsr9ssn1#

你管理的太多了,已经被启动器和导入管理了。

properties>
    <java.version>17</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <google-cloud-gcp-dependencies.version>4.5.1</google-cloud-gcp-dependencies.version>
    <spring-cloud.version>2022.0.3</spring-cloud.version>
    <jsoup.version>1.10.2</jsoup.version>
    <h2.version>1.4.200</h2.version>
    <apache-common-text>1.10.0</apache-common-text>
    <modelmapper.version>2.3.5</modelmapper.version>
    <com.jayway.jsonpath.version>2.6.0</com.jayway.jsonpath.version>
    <flyway-core.version>9.5.1</flyway-core.version>
    <postgresql.version>42.4.3</postgresql.version>
    <snakeyaml.version>1.32</snakeyaml.version>
<properties>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.0.8</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>spring-cloud-gcp-dependencies</artifactId>
      <version>${google-cloud-gcp-dependencies.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
    <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>

<dependencies>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-oauth2-client</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-config</artifactId>
   </dependency>
   <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-bootstrap</artifactId>
   </dependency>
   <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
      <version>3.12.0</version>
   </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-configuration-processor</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-sleuth</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-webflux</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-redis</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-thymeleaf</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
   </dependency>
   <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
   </dependency>
</dependencies>

字符串

  • spring-boot-starter-security已经拉入了Spring Security依赖项,无需再次定义它们。不在dependencyManagement中,也不作为dependencies
  • bom(作用域为importpom)用于管理依赖版本,无需再次指定它们。Spring Cloud将管理Spring Cloud Function版本。
  • 升级到Sping Boot 3.0.8以获得最新的3.0版本,Spring Cloud也是如此。

相关问题