【发布时间】:2017-04-23 03:54:58
【问题描述】:
我的微服务核心项目中有以下控制器:
package com.XYZ.microservices.core.api.version;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/version")
public class VersionController {
@Autowired
private VersionService versionService;
@RequestMapping(method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE})
public Version getVersion() {
return versionService.getVersion();
}
}
我有另一个名为产品服务的项目。我正在像这样将微服务核心导入产品服务:
dependencies {
compile("com.XYZ:microservices-core:1.0.0-RELEASE")
...
}
现在,我正在像这样初始化产品服务应用程序:
@SpringBootApplication
public class ProductServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ProductServiceApplication.class, args);
}
}
microservices-core 中的类在 product-service 中可用。但是当我运行产品服务时,我无法获取 localhost:8080/version。有人可以帮忙吗?
【问题讨论】:
-
您遇到的错误是什么?第404章?
-
是的,whitelabel 错误页面
-
能否添加启动应用程序时在输出中看到的弹簧轨迹?
标签: java spring gradle spring-boot dependency-management