• SpringCloud异常(Euruka):Application run failed java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder


    在测试Euruka作为服务注册中心的时候碰到了这个问题,错误提示如下:

     1 "C:Program FilesJavajdk1.8.0_161injava" -XX:TieredStopAtLevel=1 -........ com.fangxing.springcloud.eurukaserver.EurukaServerApplication
     2 15:04:35.690 [main] DEBUG org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: ....... file:/D:/Program%20Files/JetBrains/IntelliJ%20IDEA%202017.3.5/lib/idea_rt.jar]
     3 15:04:35.867 [background-preinit] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
     4 15:04:35.869 [background-preinit] INFO org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.0.7.Final
     5 15:04:35.884 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable.
     6 15:04:35.890 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
     7 15:04:35.892 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
     8 15:04:35.893 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
     9 15:04:35.894 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
    10 15:04:36.086 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
    11 15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator as ValidatorFactory-scoped message interpolator.
    12 15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.TraverseAllTraversableResolver as ValidatorFactory-scoped traversable resolver.
    13 15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
    14 15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
    15 15:04:36.090 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
    16 15:04:36.404 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
    17 java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
    18     at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:120)
    19     at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:84)
    20     at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:62)
    21     at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    22     at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    23     at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    24     at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
    25     at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
    26     at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    27     at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:351)
    28     at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
    29     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
    30     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
    31     at com.fangxing.springcloud.eurukaserver.EurukaServerApplication.main(EurukaServerApplication.java:16)
    32 
    33 Process finished with exit code 1

     其根本原因是依赖包的版本冲突,我的这个pom.xml文件如下:

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     4     <modelVersion>4.0.0</modelVersion>
     5 
     6     <groupId>com.fangxing.springcloud</groupId>
     7     <artifactId>euruka-server</artifactId>
     8     <version>0.0.1-SNAPSHOT</version>
     9     <packaging>jar</packaging>
    10 
    11     <name>euruka-server</name>
    12     <description>Demo project for Eureka Server</description>
    13 
    14     <parent>
    15         <groupId>org.springframework.boot</groupId>
    16         <artifactId>spring-boot-starter-parent</artifactId>
    17         <version>2.0.0.RELEASE</version>
    18         <relativePath/> <!-- lookup parent from repository -->
    19     </parent>
    20 
    21     <properties>
    22         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    23         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    24         <java.version>1.8</java.version>
    25     </properties>
    26 
    27     <dependencies>
    28         <dependency>
    29             <groupId>org.springframework.boot</groupId>
    30             <artifactId>spring-boot-starter-web</artifactId>
    31         </dependency>
    32 
    33         <dependency>
    34             <groupId>org.springframewor k.boot</groupId>
    35             <artifactId>spring-boot-starter-test</artifactId>
    36             <scope>test</scope>
    37         </dependency>
    38 
    39         
    40         <dependency>
    41             <groupId>org.springframework.cloud</groupId>
    42             <artifactId>spring-cloud-starter-eureka-server</artifactId>
    43         </dependency>
    44     </dependencies>
    45 
    46     <dependencyManagement>
    47         <dependencies>
    48             <dependency>
    49                 <groupId>org.springframework.cloud</groupId>
    50                 <artifactId>spring-cloud-dependencies</artifactId>
    51                 <version>Camden.SR3</version>
    52                 <type>pom</type>
    53                 <scope>import</scope>
    54             </dependency>
    55         </dependencies>
    56     </dependencyManagement>
    57 
    58     <build>
    59         <plugins>
    60             <plugin>
    61                 <groupId>org.springframework.boot</groupId>
    62                 <artifactId>spring-boot-maven-plugin</artifactId>
    63             </plugin>
    64         </plugins>
    65     </build>
    66 
    67 
    68 </project>

     这里用到的SpringBoot版本为2.0.0.0版本,我们调整一下版本,改用下面的pom.xml

     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     4     <modelVersion>4.0.0</modelVersion>
     5 
     6     <groupId>com.fangxing.springcloud</groupId>
     7     <artifactId>euruka-server</artifactId>
     8     <version>0.0.1-SNAPSHOT</version>
     9     <packaging>jar</packaging>
    10 
    11     <name>euruka-server</name>
    12     <description>Demo project for Eureka Server</description>
    13 
    14     <!--基于Springboot-->
    15     <parent>
    16         <groupId>org.springframework.boot</groupId>
    17         <artifactId>spring-boot-starter-parent</artifactId>
    18         <version>1.4.0.RELEASE</version>
    19         <relativePath/>
    20     </parent>
    21 
    22     <properties>
    23         <!--设置字符编码及java版本-->
    24         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    25         <java.version>1.8</java.version>
    26     </properties>
    27 
    28     <dependencies>
    29         <!--增加eureka-server的依赖-->
    30         <dependency>
    31             <groupId>org.springframework.cloud</groupId>
    32             <artifactId>spring-cloud-starter-eureka-server</artifactId>
    33         </dependency>
    34         <!--用于测试的,本例可省略-->
    35         <dependency>
    36             <groupId>org.springframework.boot</groupId>
    37             <artifactId>spring-boot-starter-test</artifactId>
    38             <scope>test</scope>
    39         </dependency>
    40     </dependencies>
    41 
    42     <!--依赖管理,用于管理spring-cloud的依赖,其中Camden.SR3是版本号-->
    43     <dependencyManagement>
    44         <dependencies>
    45             <dependency>
    46                 <groupId>org.springframework.cloud</groupId>
    47                 <artifactId>spring-cloud-dependencies</artifactId>
    48                 <version>Camden.SR3</version>
    49                 <type>pom</type>
    50                 <scope>import</scope>
    51             </dependency>
    52         </dependencies>
    53     </dependencyManagement>
    54 
    55     <build>
    56         <plugins>
    57             <plugin>
    58                 <groupId>org.springframework.boot</groupId>
    59                 <artifactId>spring-boot-maven-plugin</artifactId>
    60             </plugin>
    61         </plugins>
    62     </build>
    63 
    64 
    65 </project>

     启用正常。

    参考文档

    https://stackoverflow.com/questions/44166221/spring-boot-2-0-0-m1-nosuchmethoderror-org-springframework-boot-builder-springa

  • 相关阅读:
    制作 MarkText 的导航栏和动画背景
    某雅互动静态页面
    html5 拖拽及用 js 实现拖拽
    九宫格
    phaser3 入门实例——收集星星游戏
    Flexbox Froggy:练习 Flex 布局的小游戏
    JS30
    ElasticSearch
    JVM
    jstack命令的使用
  • 原文地址:https://www.cnblogs.com/gudi/p/8644810.html
Copyright © 2020-2023  润新知