我正在尝试调用rest端点,但在调用它时获取此信息,导致UI中出现404错误
self.master.after_idle
同一个包中有2个控制器类,具有不同的端点
2016-08-07 13:43:42.611 DEBUG 27834 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /api/v1/operations
2016-08-07 13:43:42.614 DEBUG 27834 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/api/v1/operations]
2016-08-07 13:43:42.615 DEBUG 27834 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Matching patterns for request [/api/v1/operations] are [/**]
2016-08-07 13:43:42.616 DEBUG 27834 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : URI Template variables for request [/api/v1/operations] are {}
2016-08-07 13:43:42.617 DEBUG 27834 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/api/v1/operations] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@39ead1b7]]] and 1 interceptor
我在同一个包中有另一个类:
@RestController
public class OperationRetrievalController {
@Autowired
OperationRetrievalManager operationRetrievalManager;
private static Logger logger = Logger.getLogger(OperationRetrievalController.class);
@RequestMapping("/api/v1/operations")
public ResponseEntity<List<OperationView>> requestUserOperations() {
String ssoId = "xxxxxx";
logger.info("Inside request operationRetrivel Manager +++++++++>>>>>>>>");
return new ResponseEntity<List<OperationView>>(operationRetrievalManager.retrieveOperations(ssoId), HttpStatus.OK);
}
}
这是Spring启动应用程序类:
@RestController
public class ComponentRetrievalController {
@Autowired
ComponentRetrievalManager componentRetrievalManager;
@RequestMapping(value = "api/v1/component/{sso_id}" , method=RequestMethod.GET)
public ResponseEntity<List<Component>> requestUserComponent(@PathVariable("sso_id") String ssoId) {
return new ResponseEntity<List<Component>>(componentRetrievalManager.retrieveComponents(ssoId), HttpStatus.OK);
}
}
当我删除Application.java中的所有注释并只保留@SpringBootApplication时,它会出现以下错误:
@SpringBootApplication
@EnableAutoConfiguration
@EnableJpaRepositories(basePackages="com.ge.power.bis.repositories")
@ComponentScan(basePackages="com.ge.power.bis.managers")
public class Application {
private static Logger logger = Logger.getLogger(Application.class);
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(Application.class);
ApplicationContext ctx = springApplication.run(args);
logger.info("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames)
{
logger.info(beanName);
}
}
}
答案 0 :(得分:0)
其中一个Impl类
缺少@Service答案 1 :(得分:0)
您需要将服务类标记为“ 可以制造bean ”,这样Spring的组件扫描才能制造bean和注入值。
这可以通过@Component
注释来完成。如@sromit的答案中所述,添加@Service
注释也将起作用,因为它已经继承了@Component
。 @Repository
和@Controller
也继承了@Component
注释。