Spring Boot Sping Boot 应用程序未运行,获取错误

3lxsmp7m  于 2023-06-22  发布在  Spring
关注(0)|答案(1)|浏览(168)
    • 当我尝试将Java版本从Java 8更改为Java 17时,我会出现以下异常。我还改变了我的 Spring 启动版本以前我使用的是 Spring 启动1.3.3.RELEASE版本。请帮帮我**
  • 线程"main"出现异常java. lang. NoClassDefFoundError:org/springframework/core/metrics/ApplicationStartup * at org.springframework.boot.SpringApplication.(SpringApplication.java:232)at org.springframework.boot.SpringApplication.(SpringApplication.java:245)at www.example.com(SpringApplication.java:1303)at www.example.com(SpringApplication.java:1292)at com. aujas. keystore. microservice. KeystoreController. main(KeystoreController.java:43)* Caused by:org.springframework.boot.SpringApplication.run 2019 - 05 - 21 00:00:00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00:00 00 00:00 00 00:00 00 00:00 00 00:00 00 00:00 00 00:00 00 00:00 00 00:00 00 00:00 00 00 00:00 00 00 00 00:00 00 00:00 00 00 00 00:00 00 00 00:00 00 00 00 00 00:00 00 00 00 00:00 00 00 00 00 00 00:00 00 00 00 00:00 00 00 00 00 00:00 00 00 00org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) at com.aujas.keystore.microservice.KeystoreController.main(KeystoreController.java:43) *Caused by: java.lang.ClassNotFoundException: org.springframework.core.metrics.ApplicationStartup at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)* at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 5 more
    • 这是我的porm.xml文件。**

4.0.0

<groupId>codesign</groupId>
<artifactId>microservice</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>microservice</name>
<url>http://maven.apache.org</url>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.12</version>
    <relativePath />
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>17</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-zuul</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
          <exclusion>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-logging</artifactId>
          </exclusion>
       </exclusions>
    </dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-xml</artifactId>
    </dependency>

    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcmail-jdk16</artifactId>
        <version>1.46</version>
    </dependency>
    
    <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcpg-jdk15on</artifactId>
        <version>1.49</version>
    </dependency>
    
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
    </dependency>

    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.0</version>
    </dependency>
    
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-processing</artifactId>
        <version>2.19</version>
    </dependency>
    
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-client</artifactId>
        <version>2.20</version>
        <scope>provided</scope>
    </dependency>
    
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
    </dependency>
    
    <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.3</version>
    </dependency>
    
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
    </dependency>
    
    <dependency>
        <groupId>biz.paluch.logging</groupId>
        <artifactId>logstash-gelf</artifactId>
        <version>1.11.2</version>
    </dependency>
    
    <!-- Add Log4j2 Dependency -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>
    
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Brixton.RC1</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            
        </plugin>
    </plugins>

</build>
    • 我也更新了最新的依赖项**
<dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcmail-jdk16</artifactId>
            <version>1.46</version>
        </dependency>
        
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpg-jdk15on</artifactId>
            <version>1.49</version>
        </dependency>
        
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-processing</artifactId>
            <version>3.1.2</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>3.1.2</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>3.1.2</version>
        </dependency>
xkftehaa

xkftehaa1#

Sping Boot 2.7不是你想要的Java 17版本。你需要Sping Boot 3。
在那之后,你现在基本上就靠自己了,事情仍然可能出错,这取决于类加载问题,依赖注入不一致等。等等的。
我一直致力于从Java 8移植到基于Sping Boot 的Java 17,这并不是一帆风顺的。迁移指南提供了帮助,但是如果您的依赖项组合超出了主流,那么它们只能帮助您到目前为止。如果你不提供更多的信息,没有人能告诉你更多。

相关问题