线程“主”中的Spring引导异常java.lang.NoSuchMethodError:org.springframew ..(版本问题)

时间:2019-01-30 12:59:57

标签: spring spring-boot spring-data-jpa spring-cloud spring-cloud-netflix

运行服务器时出现异常。我知道这是Spring bootspring-cloud的版本问题。但是我正在使用spring boot 1.4.2.RELEASE,目前正在使用spring cloud Finchley.SR1

  

什么是带有Spring Boot 1.4.2.RELEASE的Spring Cloud合适的版本?

在下面获取异常:

Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Class;)V
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:170)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:104)
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:70)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:68)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:337)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
    at com.sarathi5.Sarathi5TestCase2Application.main(Sarathi5TestCase2Application.java:14)

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.example</groupId>
    <artifactId>TestCase2</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>TestCase2</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
        <!-- <version>2.0.1.RELEASE</version> -->
        <relativePath/><!--  lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <drools.version>6.2.0.Final</drools.version><!--7.6.0.Final  -->
        <!--<spring-cloud.version></spring-cloud.version> -->
    </properties>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
 <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
 </dependency>
<dependencies>
<dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.springframework.cloud</groupId>
          <artifactId>spring-cloud-dependencies</artifactId>
          <version>Finchley.SR1</version>
           <type>pom</type>
          <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>
</project>

请帮助我什么问题?

2 个答案:

答案 0 :(得分:0)

Edgware.SR5是应该兼容的最新版本。

答案 1 :(得分:0)

问题解决了。我将import pandas as pd from pandas_datareader import data as pdr import fix_yahoo_finance as yf import datetime yf.pdr_override() #these are the stocks we can choose in our portfolio stocks = [ 'AAPL' ] startD = '2017-01-01' endD = '2019-01-29' start_date = pd.to_datetime(startD) end_date = pd.to_datetime(endD) data = pdr.get_data_yahoo(stocks, start=start_date, end=end_date)#['Adj Close'] # using resample to group daily bar into monthly bar n = 1 mon_data=pd.DataFrame(data['Adj Close'].resample('BM').apply(lambda x: x[-1-n])) end_of_months = mon_data.index.tolist() end_of_months[-1] = data.index[-1] mon_data.index = end_of_months mon_data.index = mon_data.index - datetime.timedelta(days=n) #downloading the data from Yahoo! Finance def download_data(stocks): data = pdr.get_data_yahoo(stocks, start=start_date, end=end_date)['Adj Close'] return data if __name__ == "__main__": data = download_data(stocks) print(mon_data) 依赖项版本spring boot更新为1.4.2.RELEASE。和其支撑1.5.19.RELEASE

提供

与版本相关的明确信息链接:

Spring Cloud Edgware发行说明: https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Edgware-Release-Notes

Spring Cloud Camden发行说明: https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Camden-Release-Notes

Spring Cloud Finchley发行说明: https://github.com/spring-projects/spring-cloud/wiki/spring-cloud-finchley-release-notes

  

版本已更新,春季靴子:1.5.19-RELEASE和spring   云:Edgware.SR5

spring-cloud dependency management Edgware.SR5

更新依赖项:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
<!--        <version>1.4.2.RELEASE</version> -->
        <version>1.5.19.RELEASE</version>
        <!-- <version>2.0.1.RELEASE</version> -->
        <relativePath/><!--  lookup parent from repository -->
    </parent>

更新这两个依赖项后,只需更新maven项目(右键单击project-> maven-> update)并进行mvn全新安装即可。

问题已解决。