您好,登录后才能下订单哦!
这篇文章主要介绍了如何实现java版spring cloud+spring boot+redis多租户社交电子商务平台,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
1. 创建一个名为particle-common-eureka的maven项目,继承particle-commonservice,具体的pom.xml配置文件如下:
Xml代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ml.honghu</groupId>
<artifactId>particle-commonservice</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>particle-commonservice-eureka</artifactId>
<packaging>jar</packaging>
<name>particle-commonservice-eureka</name>
<description>particle-commonservice project for Spring Boot</description>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>1</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>2</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
</project>
2. 在启动类入口引用eureka的相关配置,代码如下:
Java代码
package com.ml.honghu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class ServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class, args);
}
}
3. 配置application.yml文件
# server (eureka 默认端口为:8761)
server:
port: 8761
# spring
spring:
application:
name: particle-commonservice-erueka
# eureka
eureka:
client:
# 是否注册到eureka
register-with-eureka: true
# 是否从eureka获取注册信息
fetch-registry: false
availability-zones:
honghu: honghuZone
service-url:
honghuZone: http://honghu:123456@localhost:8761/eureka/
defaultZone: http://honghu:123456@localhost:8761/eureka/
instance:
prefer-ip-address: true
hostname: localhost
metadataMap:
zone: honghuZone
user: ${security.user.name}
password: {security.user.password}
# 指定环境
environment: dev
#指定数据中心
datacenter: honghu
# 关闭自我保护模式
server:
enable-self-preservation: false
#设置清理无效节点的时间间隔,默认60000,即是60s
eviction-interval-timer-in-ms: 60000
# 服务认证
security:
basic:
enabled: true
user:
name: honghu
password: 123456
management:
security:
enabled: false
4. 增加项目的log机制和打包运行机制(后面我们会详细编写针对于Linux Centos下的打包部署机制)
5. 自此整个项目部署完成,通过手动方式进行Run As --> Spring Boot App,运行结果如下:
控制台运行结果:
访问控制台并登陆:
控制台运行效果:
感谢你能够认真阅读完这篇文章,希望小编分享的“如何实现java版spring cloud+spring boot+redis多租户社交电子商务平台”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。