# Starter集成方案
应用嵌入公共资源模式,即集成Strater,应用将公共资源项目当做类库嵌入到系统内。
- 开发依赖包
<dependency>
<groupId>com.primeton.gocom</groupId>
<artifactId>public-resource-starter</artifactId>
<version>8.3.3.0</version>
</dependency>
- 配置文件
配置文件内容参考发布介质,具体配置参数设置参考微服务版安装指南
- 启动类添加com.primeton.components.rest.annotation包扫描
参考代码
@SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient
@ComponentScan(basePackages = {"com.primeton.components.rest.annotation", "com.primeton.gocom.starterdemo"})
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
- 接口说明
参考服务的/swagger-ui.html文档
- 使用方式
直接使用@Autowired 方式注入service接口即可调用对应的API方法。所有service接口均在public-resource-api模块中。
参考代码
@Api(tags = "集成starter测试")
@RestController
@RequestMapping(value = "/starter", consumes = {APPLICATION_JSON_UTF8_VALUE}, produces = {APPLICATION_JSON_UTF8_VALUE})
public class testStarterController {
private static final Logger LOGGER = LoggerFactory.getLogger(testStarterController.class);
@Autowired
private IDataSourceEngineService dsEngineService;
@GetMapping(value = "/{id}")
public DatasourceEngine queryById(@ApiParam("存算引擎ID") @NotBlank @PathVariable("id") String id) {
DatasourceEngine datasourceEngine = dsEngineService.queryById(id);
return datasourceEngine;
}
}