Commit c5bb6143baa9a9c2a30fd2ef37d58eea52842063
1 parent
64c861aa
nacos server本地化jar方式启动,简化开发
Showing
7 changed files
with
173 additions
and
23 deletions
jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-cloud/nacos/jeecg-dev.yaml
@@ -35,9 +35,9 @@ spring: | @@ -35,9 +35,9 @@ spring: | ||
35 | 35 | ||
36 | datasource: | 36 | datasource: |
37 | master: | 37 | master: |
38 | - url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai | ||
39 | - username: root | ||
40 | - password: root | 38 | + url: jdbc:mysql://${MYSQL-HOST:jeecg-boot-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:jeecg-boot}?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai |
39 | + username: ${MYSQL-USER:root} | ||
40 | + password: ${MYSQL-PWD:root} | ||
41 | driver-class-name: com.mysql.cj.jdbc.Driver | 41 | driver-class-name: com.mysql.cj.jdbc.Driver |
42 | # 多数据源配置 | 42 | # 多数据源配置 |
43 | #multi-datasource1: | 43 | #multi-datasource1: |
@@ -48,7 +48,7 @@ spring: | @@ -48,7 +48,7 @@ spring: | ||
48 | #redis 配置 | 48 | #redis 配置 |
49 | redis: | 49 | redis: |
50 | database: 0 | 50 | database: 0 |
51 | - host: 127.0.0.1 | 51 | + host: jeecg-boot-redis |
52 | lettuce: | 52 | lettuce: |
53 | pool: | 53 | pool: |
54 | max-active: 8 #最大连接数据库连接数,设 0 为没有限制 | 54 | max-active: 8 #最大连接数据库连接数,设 0 为没有限制 |
@@ -60,7 +60,7 @@ spring: | @@ -60,7 +60,7 @@ spring: | ||
60 | port: 6379 | 60 | port: 6379 |
61 | #rabbitmq配置 | 61 | #rabbitmq配置 |
62 | rabbitmq: | 62 | rabbitmq: |
63 | - host: 127.0.0.1 | 63 | + host: jeecg-boot-rabbitmq |
64 | username: guest | 64 | username: guest |
65 | password: guest | 65 | password: guest |
66 | port: 5672 | 66 | port: 5672 |
@@ -129,7 +129,7 @@ jeecg : | @@ -129,7 +129,7 @@ jeecg : | ||
129 | #xxl-job配置 | 129 | #xxl-job配置 |
130 | xxljob: | 130 | xxljob: |
131 | enabled: false | 131 | enabled: false |
132 | - adminAddresses: http://127.0.0.1:9080/xxl-job-admin | 132 | + adminAddresses: http://jeecg-boot-xxljob:9080/xxl-job-admin |
133 | appname: ${spring.application.name} | 133 | appname: ${spring.application.name} |
134 | accessToken: '' | 134 | accessToken: '' |
135 | logPath: logs/jeecg/job/jobhandler/ | 135 | logPath: logs/jeecg/job/jobhandler/ |
@@ -142,7 +142,7 @@ jeecg : | @@ -142,7 +142,7 @@ jeecg : | ||
142 | data-type: yml | 142 | data-type: yml |
143 | #分布式锁配置 | 143 | #分布式锁配置 |
144 | redisson: | 144 | redisson: |
145 | - address: 127.0.0.1:6379 | 145 | + address: jeecg-boot-redis:6379 |
146 | password: | 146 | password: |
147 | type: STANDALONE | 147 | type: STANDALONE |
148 | enabled: true | 148 | enabled: true |
jeecg-boot/jeecg-cloud-module/docker-compose.yml
@@ -28,28 +28,18 @@ services: | @@ -28,28 +28,18 @@ services: | ||
28 | hostname: jeecg-boot-redis | 28 | hostname: jeecg-boot-redis |
29 | 29 | ||
30 | jeecg-boot-nacos: | 30 | jeecg-boot-nacos: |
31 | - restart: always | ||
32 | - image: nacos/nacos-server:1.4.0 | ||
33 | - container_name: jeecg-boot-nacos | ||
34 | - hostname: jeecg-boot-nacos | 31 | + restart: on-failure |
32 | + build: | ||
33 | + context: ./jeecg-cloud-nacos | ||
35 | ports: | 34 | ports: |
36 | - 8848:8848 | 35 | - 8848:8848 |
37 | depends_on: | 36 | depends_on: |
38 | - jeecg-boot-mysql | 37 | - jeecg-boot-mysql |
39 | -# volumes: | ||
40 | -# - ./init/docker-startup.sh:/home/nacos/bin/docker-startup.sh | ||
41 | -# - ./init/application.properties:/home/nacos/conf/application.properties | ||
42 | - environment: | ||
43 | - MODE: standalone | ||
44 | - PREFER_HOST_MODE: hostname | ||
45 | - SPRING_DATASOURCE_PLATFORM: mysql | ||
46 | - MYSQL_SERVICE_HOST: jeecg-boot-mysql | ||
47 | - MYSQL_SERVICE_PORT: 3306 | ||
48 | - MYSQL_SERVICE_USER: root | ||
49 | - MYSQL_SERVICE_PASSWORD: root | ||
50 | - MYSQL_SERVICE_DB_NAME: nacos | 38 | + container_name: jeecg-boot-nacos |
39 | + hostname: jeecg-boot-nacos | ||
51 | 40 | ||
52 | jeecg-boot-gateway: | 41 | jeecg-boot-gateway: |
42 | + restart: on-failure | ||
53 | build: | 43 | build: |
54 | context: ./jeecg-cloud-gateway | 44 | context: ./jeecg-cloud-gateway |
55 | ports: | 45 | ports: |
jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/Dockerfile
0 → 100644
1 | +FROM anapsix/alpine-java:8_server-jre_unlimited | ||
2 | + | ||
3 | +MAINTAINER jeecgos@163.com | ||
4 | + | ||
5 | +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | ||
6 | + | ||
7 | +RUN mkdir -p /jeecg-cloud-nacos | ||
8 | + | ||
9 | +WORKDIR /jeecg-cloud-nacos | ||
10 | + | ||
11 | +EXPOSE 8848 | ||
12 | + | ||
13 | +ADD ./target/jeecg-cloud-nacos-2.4.2.jar ./ | ||
14 | + | ||
15 | +CMD sleep 5;java -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jeecg-cloud-nacos-2.4.2.jar | ||
0 | \ No newline at end of file | 16 | \ No newline at end of file |
jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + <parent> | ||
6 | + <artifactId>jeecg-cloud-module</artifactId> | ||
7 | + <groupId>org.jeecgframework.boot</groupId> | ||
8 | + <version>2.4.2</version> | ||
9 | + </parent> | ||
10 | + <artifactId>jeecg-cloud-nacos</artifactId> | ||
11 | + <name>jeecg-cloud-nacos</name> | ||
12 | + <description>nacos启动模块</description> | ||
13 | + | ||
14 | + <dependencies> | ||
15 | + <dependency> | ||
16 | + <groupId>org.apache.tomcat.embed</groupId> | ||
17 | + <artifactId>tomcat-embed-jasper</artifactId> | ||
18 | + </dependency> | ||
19 | + <dependency> | ||
20 | + <groupId>org.springframework.boot</groupId> | ||
21 | + <artifactId>spring-boot-starter-security</artifactId> | ||
22 | + </dependency> | ||
23 | + <dependency> | ||
24 | + <groupId>org.jeecgframework.nacos</groupId> | ||
25 | + <artifactId>nacos-naming</artifactId> | ||
26 | + <version>1.4.1</version> | ||
27 | + </dependency> | ||
28 | + <dependency> | ||
29 | + <groupId>org.jeecgframework.nacos</groupId> | ||
30 | + <artifactId>nacos-istio</artifactId> | ||
31 | + <version>1.4.1</version> | ||
32 | + </dependency> | ||
33 | + <dependency> | ||
34 | + <groupId>org.jeecgframework.nacos</groupId> | ||
35 | + <artifactId>nacos-config</artifactId> | ||
36 | + <version>1.4.1</version> | ||
37 | + </dependency> | ||
38 | + <dependency> | ||
39 | + <groupId>org.jeecgframework.nacos</groupId> | ||
40 | + <artifactId>nacos-console</artifactId> | ||
41 | + <version>1.4.1</version> | ||
42 | + </dependency> | ||
43 | + </dependencies> | ||
44 | + | ||
45 | + <build> | ||
46 | + <plugins> | ||
47 | + <plugin> | ||
48 | + <groupId>org.springframework.boot</groupId> | ||
49 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
50 | + </plugin> | ||
51 | + </plugins> | ||
52 | + </build> | ||
53 | + | ||
54 | +</project> |
jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/java/com/alibaba/nacos/JeecgNacosApplication.java
0 → 100644
1 | +package com.alibaba.nacos; | ||
2 | + | ||
3 | +import org.springframework.boot.SpringApplication; | ||
4 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
5 | +import org.springframework.boot.web.servlet.ServletComponentScan; | ||
6 | +import org.springframework.scheduling.annotation.EnableScheduling; | ||
7 | + | ||
8 | +/** | ||
9 | + * Nacos 启动类 | ||
10 | + * 引用的nacos console 源码运行,简化开发 | ||
11 | + * 生产建议从官网下载最新版配置运行 | ||
12 | + * @author zyf | ||
13 | + */ | ||
14 | +@SpringBootApplication(scanBasePackages = "com.alibaba.nacos") | ||
15 | +@ServletComponentScan | ||
16 | +@EnableScheduling | ||
17 | +public class JeecgNacosApplication { | ||
18 | + | ||
19 | + /** | ||
20 | + * 是否单机模式启动 | ||
21 | + */ | ||
22 | + private static String standalone = "true"; | ||
23 | + | ||
24 | + /** | ||
25 | + * 是否开启鉴权 | ||
26 | + */ | ||
27 | + private static String enabled = "false"; | ||
28 | + | ||
29 | + public static void main(String[] args) { | ||
30 | + System.setProperty("nacos.standalone", standalone); | ||
31 | + System.setProperty("nacos.core.auth.enabled", enabled); | ||
32 | + System.setProperty("server.tomcat.basedir","logs"); | ||
33 | + SpringApplication.run(JeecgNacosApplication.class, args); | ||
34 | + } | ||
35 | +} |
jeecg-boot/jeecg-cloud-module/jeecg-cloud-nacos/src/main/resources/application.yml
0 → 100644
1 | +server: | ||
2 | + port: 8848 | ||
3 | + servlet: | ||
4 | + contextPath: /nacos | ||
5 | + tomcat: | ||
6 | + accesslog: | ||
7 | + enabled: true | ||
8 | + pattern: '%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i' | ||
9 | + basedir: '' | ||
10 | +spring: | ||
11 | + datasource: | ||
12 | + platform: mysql | ||
13 | +db: | ||
14 | + num: 1 | ||
15 | + password: | ||
16 | + '0': ${MYSQL-PWD:root} | ||
17 | + url: | ||
18 | + '0': jdbc:mysql://${MYSQL-HOST:jeecg-boot-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:nacos}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true | ||
19 | + user: | ||
20 | + '0': ${MYSQL-USER:root} | ||
21 | +management: | ||
22 | + metrics: | ||
23 | + export: | ||
24 | + elastic: | ||
25 | + enabled: false | ||
26 | + influx: | ||
27 | + enabled: false | ||
28 | +nacos: | ||
29 | + core: | ||
30 | + auth: | ||
31 | + caching: | ||
32 | + enabled: true | ||
33 | + default: | ||
34 | + token: | ||
35 | + expire: | ||
36 | + seconds: 18000 | ||
37 | + secret: | ||
38 | + key: SecretKey012345678901234567890123456789012345678901234567890123456789 | ||
39 | + enabled: false | ||
40 | + system: | ||
41 | + type: nacos | ||
42 | + istio: | ||
43 | + mcp: | ||
44 | + server: | ||
45 | + enabled: false | ||
46 | + naming: | ||
47 | + empty-service: | ||
48 | + auto-clean: true | ||
49 | + clean: | ||
50 | + initial-delay-ms: 50000 | ||
51 | + period-time-ms: 30000 | ||
52 | + security: | ||
53 | + ignore: | ||
54 | + urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** | ||
55 | + standalone: true | ||
0 | \ No newline at end of file | 56 | \ No newline at end of file |
jeecg-boot/jeecg-cloud-module/pom.xml
@@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
16 | <module>jeecg-cloud-gateway</module> | 16 | <module>jeecg-cloud-gateway</module> |
17 | <module>jeecg-cloud-monitor</module> | 17 | <module>jeecg-cloud-monitor</module> |
18 | <module>jeecg-cloud-xxljob</module> | 18 | <module>jeecg-cloud-xxljob</module> |
19 | + <module>jeecg-cloud-nacos</module> | ||
19 | </modules> | 20 | </modules> |
20 | 21 | ||
21 | 22 |