You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.2 KiB
80 lines
2.2 KiB
# 项目接入到SOP
|
|
|
|
以springboot项目为例,完整项目可参考sop-example下的sop-story
|
|
|
|
- pom.xml添加版本配置
|
|
|
|
```xml
|
|
<properties>
|
|
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
|
|
<!-- nacos spring cloud版本号 -->
|
|
<spring-cloud-alibaba-nacos.version>0.9.0.RELEASE</spring-cloud-alibaba-nacos.version>
|
|
<!-- nacos客户端版本号 -->
|
|
<nacos-client.version>1.1.0</nacos-client.version>
|
|
</properties>
|
|
```
|
|
|
|
- pom.xml添加SpringCloud支持
|
|
|
|
```xml
|
|
<dependencyManagement>
|
|
<dependencies>
|
|
<dependency>
|
|
<groupId>org.springframework.cloud</groupId>
|
|
<artifactId>spring-cloud-dependencies</artifactId>
|
|
<version>Greenwich.RELEASE</version>
|
|
<type>pom</type>
|
|
<scope>import</scope>
|
|
</dependency>
|
|
</dependencies>
|
|
</dependencyManagement>
|
|
```
|
|
|
|
- pom.xml依赖sop-service-common和nacos服务发现
|
|
|
|
```xml
|
|
|
|
<dependency>
|
|
<groupId>com.gitee.sop</groupId>
|
|
<artifactId>sop-service-common</artifactId>
|
|
<version>最新版本</version>
|
|
</dependency>
|
|
|
|
<!-- 使用nacos注册中心
|
|
版本 0.2.x.RELEASE 对应的是 Spring Boot 2.x 版本,版本 0.1.x.RELEASE 对应的是 Spring Boot 1.x 版本。
|
|
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-alibaba-nacos-discovery
|
|
-->
|
|
<dependency>
|
|
<groupId>org.springframework.cloud</groupId>
|
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
<version>${spring-cloud-alibaba-nacos.version}</version>
|
|
</dependency>
|
|
<dependency>
|
|
<groupId>com.alibaba.nacos</groupId>
|
|
<artifactId>nacos-client</artifactId>
|
|
<version>${nacos-client.version}</version>
|
|
</dependency>
|
|
<!-- 注册中心end -->
|
|
```
|
|
|
|
- application.properties配置文件添加
|
|
|
|
```properties
|
|
server.port=2222
|
|
# 服务名称
|
|
spring.application.name=story-service
|
|
# nacos注册中心
|
|
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
|
|
```
|
|
|
|
- 在springboot启动类上添加`@EnableDiscoveryClient`
|
|
- 新增一个配置类,继承`AlipayServiceConfiguration.java`,内容为空
|
|
|
|
```java
|
|
@Configuration
|
|
public class OpenServiceConfig extends AlipayServiceConfiguration {
|
|
|
|
}
|
|
```
|
|
|
|
到此准备工作就完成了,接下来可前往`新增接口`查看如何新增接口。
|
|
|