首先从gitee中克隆人人开源项目,建库建表,逆向工程生成基本增删改查
<!--common公共模块管理cloud版本为2.1.0.RELEASE--> <dependencyManagement> <dependencies> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-alibaba-dependencies</artifactId> <version>2.1.0.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>-----------------------------------以下业务模块,创建时构建web和feign----------------------------------
<!--依赖版本管理 jdk1.8,cloud版本为Greenwich.SR3--> <properties> <java.version>1.8</java.version> <spring-cloud.version>Greenwich.SR3</spring-cloud.version> </properties> <!--springcloud版本为Greenwich.SR3--> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement><!--springboot版本为2.1.8.RELEASE--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.8.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent><!--springboot整合feign和web--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
整合nacos:
1. 安装nacos软件
2. pom文件引入依赖
<!--公共模块引入 服务注册与发现--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> </dependency>
3. 在配置文件中注册nacos
server: port: 8080 #本服务端口号为 8080 spring: cloud: nacos: discovery: server-addr: localhost:8848 #nacos注册中心地址为 localhost:8848 application: name: gulimall-member #本服务名为 gulimall-member
4. 在主启动类上加上注解 @EnableDiscoveryClient
@EnableDiscoveryClient //表示开开启服务发现与注册功能 @SpringBootApplication public class GulimallOrderApplication { public static void main(String[] args) { SpringApplication.run(GulimallOrderApplication.class, args); } }
5. 浏览器访问 http://localhost:8848/nacos 账户密码默认为 nacos
6. 展示服务列表