1.
方法如果有参数的话,需要添加@RequestParam注解,然后小括号里面添加对应的参数名称,
这里不要用@PathVariable注解,因为在openFeign调用过程中会出现调用错误,服务器内部会报错。
2.
3.
在controller层,如果是单个参数的话,也尽量用@RequestParam注解,不要使用rest风格,如果参数是对象的话使用@RequestBoday注解
在服务消费方添加openFeign的依赖
<!--OpenFeign-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
如果在启动项目时候报如下错误,加红色圈中内容即可
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).