1. 程式人生 > >【SpringBoot】RestTemplate呼叫報錯:'org.springframework.web.client.RestTemplate' that could not be found.

【SpringBoot】RestTemplate呼叫報錯:'org.springframework.web.client.RestTemplate' that could not be found.

    RestTemplate引入方式為:
@Autowired
public RestTemplate restTemplate;
 時報錯,錯誤資訊如下
錯誤:'org.springframework.web.client.RestTemplate' that could not be found.
   
改為:
 @Bean
          @LoadBalanced
          public RestTemplate restTemplate() {
              return new RestTemplate();
          }
    
    String providerMsg = restTemplate().getForEntity("http://localhost:8009/ecif-business/PrpObject/test",String.class).getBody();
    System.out.println("Hello,Customer! msg from provider : <br/><br/> " + providerMsg);;
   後即正確
   此種方式為Spring Boot<=1.3時使用的,在>=1.4版本後,可以通過RestTemplateBuilder來使用。

相關推薦

SpringBootRestTemplate呼叫'org.springframework.web.client.RestTemplate' that could not be found.

    RestTemplate引入方式為:@Autowiredpublic RestTemplate restTemplate; 時報錯,錯誤資訊如下錯誤:'org.springframework.web.client.RestTemplate' that could n

mybatismybatis訪問org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

配置 esp 文件中 map XML 需要 r.java文件 指定 space mybatis訪問報錯:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 需要檢

Eclipse中maven專案org.springframework.web.filter.CharacterEncodingFilter

寫了一個demo,發現在tomcat中部署完專案,啟動時報錯。 1,問題描述 2,解決辦法 1)程式在部署完成後報錯,說明是程式是編譯通過的,即編譯編譯路徑Java Build Path沒問題。 2)此時檢視 專案Properties—Deployment

Feign呼叫The bean 'XXX.FeignClientSpecification', defined in null, could not be registered....的解決辦法

升級Spring Boot 2.1.0 Spring Cloud Greenwich.M1  版本後,在2個Feign介面類內定義相同的名字,  @FeignClient(name = 相同的名字 就會出現報錯,在之前的版本不會提示報錯,報錯內容為The bean 'XXX.

Maven項目下啟動後Eclipseorg.springframework.web.context.ContextLoaderListener

star load lex ini 並且 啟動 conf erb 嚴重 嚴重: Error configuring application listener of class org.springframework.web.context.ContextLoaderList

Xamarin Android移動開發藍芽列印編碼(android 下面提示 Encoding 936 data could not be found.)

Xamarin Android移動開發藍芽列印編碼報錯:Encoding 936 data could not be found. Make sure you have correct international codeset assembly installed and

c++=過載,沒有合適的複製建構函式

不想看太多的朋友看這句就行了:在你的複製建構函式作為引數傳進去的那個物件前加個const. 是這樣的,在寫機器學習作業的時候,遇到了很多矩陣演算法,為了處理上的方便,我寫了一個矩陣類Matrix,如下

Springboot啟動applicationField userMapper in xxx required a bean of type xx that could not be found

2018-07-24 15:38:07.647 INFO 20368 --- [ main] c.e.playspring.PlayspringApplication : Starting PlayspringApplication on LAP

啟動項目org.springframework.beans.factory.UnsatisfiedDependencyException

ini ali 監聽 exp date ram factor 接口 xml文件 dubbo項目: 啟動項目報錯:(web端) org.springframework.beans.factory.UnsatisfiedDependencyException: Error cr

org.springframework.http.converter.json.MappingJacksonHttpMessageConverter

log beans 而在 itme manager 解決辦法 man ali hand org.springframework.http.converter.json.MappingJacksonHttpMessageConverter 1、錯誤描述 嚴重:

java項目連接jdbccom.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server

image mysq reat jar包 tor ima 新版 ransient java項目 java項目連接jdbc報錯:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Coul

SpringCloud消費者'org.springframework.cloud.openfeign.FeignContext' that could not be found.

springboot版本:2.0.2.RELEASE,springcloud版本:Finchley.RC2 在使用Feign消費服務者時,首先引入feign的jar包 <dependency> <groupId>org.springframework.cloud

spring更新cloborg.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL

org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO IOM_MSG(IN_

部署Spring AOPorg.springframework.beans.factory.BeanCreationException解決方法

在部署Spring AOP時出現如下錯誤: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminbean' defined in class path

Spring-MVCorg.springframework.validation.BeanPropertyBindingResult

完成報錯如下: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors Field error in object ‘

Eclipse svn org.tigris subversion javahl.ClientException: Working copy not locked;this is proba

使用MyEclipse進行Java開發,用SVN進行版本控制。程式碼修改完後執行Commit,然後Update,提示如下類似的錯誤: org.tigris subversion javahl.ClientException: Working copy not locked;

tomcat啟動1,啟動顯示 [org.springframework.web.servlet.DispatcherServlet]FrameworkServlet 'springMvc'

1,啟動報錯顯示 [org.springframework.web.servlet.DispatcherServlet]FrameworkServlet 'springMvc': initialization completed in 382 ms Jun 01, 201

SSHorg.hibernate.hql.ast.QuerySyntaxException: User is not mapped [select o from User o where 1=1

Struts has detected an unhandled exception:  Messages: 1.User is not mapped [select o from User o where 1=1 order by o.id asc] 2.User is not mapped [select

springboot 啟動 Field roleMapper in ‘’ required a bean of type '' that could not be found.

其實在報錯資訊上就能看出來問題是什麼,但是因為現在文件少,不容易找到解決方案。特此記錄 意思是掃描不到mapper層,我們需要在Application.java這個啟動檔案上加一個註解告訴spri

eclipse 運行 mapreduce程序 No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String).

ads 不變 load style 程序 ble .class loader val 報錯信息 17/07/06 17:00:27 WARN mapred.JobClient: Use GenericOptionsParser for parsing the argumen