您好,登錄后才能下訂單哦!
這篇文章主要介紹了如何實現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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。