@RestController
@RequestMapping("/page")
public class PageController {
@Autowired
private RestTemplate restTemplate;
@GetMapping("/getProduct/{id}")
public Products getProduct(@PathVariable Integer id){
String url = "http://127.0.0.1:9000/product/query/"+id;
Products forObject = restTemplate.getForObject(url, Products.class);
return forObject;
}
}
Share an error report solution
Adding @ pathvariable annotation to the request parameter solves the problem
Read More:
- ‘dependencies.dependency.version‘ for org.springframework.cloud:spring-cloud-starter-openfeign:jar
- Error creating bean with name ‘org.springframework.security.oauth2.config.annotation.web.configurati
- Solution in idea java.lang.ClassNotFoundException : org.springframework.web . context.ContextLoaderListener
- org.springframework.dao.InvalidDataAccessApiUsageException: Bean object must not be null; nested exc
- SpringCloud GateWay Failed to instantiate [org.springframework.cloud.gateway.discovery.DiscoveryL…
- [Solved] Error in registering Eureka for spring cloud micro service: classnotfoundexception: org.apache.http.conn.scheme.schemeregistry
- Spring nested exception is java.lang.NoClassDefFoundError: org/springframework/core/MethodClassKey
- This (code, message, data: null) still exists after importing spring cloud project into Lombok; the data in the project is unrecognized
- When SSM + Maven project is running, it is prompted that org.springframework.web.servlet.dispatcherserservlet cannot be found
- Unable to read Scheme Document ‘ http://www.springframework.org/schema/beans/spring-beans-4.1.xsd ‘ [How to Fix]
- Spring configuration error: org.springframework.beans . factory.BeanCreationException : Error creating bean with name ‘m
- There is more than one Web fragment with the same name: “spring_web”.
- org.apache.ibatis.type.TypeException: Error setting non null for parameter #4 with JdbcType null
- Unable to read scheme document‘ http://www.springframework.org/schema/spring-context.xsd The solution to the problem
- Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.4.0:repackage failed
- Common errors reported by Eureka in spring cloud
- Using jsoup to parse web pages and report null errors
- “503 Service Unavailable” error when connecting to vCenter Server using vSphere Web Client (2121043)
- Spring cloud Alibaba 2020.0.rc1 does not integrate ribbon error reporting unknownhostexception
- Spring cloud is a big hole. Failed to start bean ‘eurekaAutoServiceRegistration’