commit 3d6b6cb95f7c8af3fb263105a707620a77aa4fde
Author: Bunny <1319900154@qq.com>
Date: Sun Feb 9 12:48:19 2025 +0800
feat(初始化): 开启两个微服务
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..549e00a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..8c20524
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,44 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.3.2
+
+
+
+ cn.bunny
+ cloud1
+ 0.0.1-SNAPSHOT
+ pom
+ cloud1
+ cloud1
+
+ service
+
+
+
+ 17
+
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ 2023.0.3.2
+ pom
+ import
+
+
+
+
diff --git a/service/cloud-demo1/pom.xml b/service/cloud-demo1/pom.xml
new file mode 100644
index 0000000..0eb59d6
--- /dev/null
+++ b/service/cloud-demo1/pom.xml
@@ -0,0 +1,23 @@
+
+ 4.0.0
+
+ cn.bunny
+ service
+ 0.0.1-SNAPSHOT
+
+
+ cloud-demo1
+ jar
+
+ cloud-demo1
+ https://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+
+
diff --git a/service/cloud-demo1/src/main/java/cn/bunny/Cloud1Application.java b/service/cloud-demo1/src/main/java/cn/bunny/Cloud1Application.java
new file mode 100644
index 0000000..b74e1e4
--- /dev/null
+++ b/service/cloud-demo1/src/main/java/cn/bunny/Cloud1Application.java
@@ -0,0 +1,13 @@
+package cn.bunny;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+@EnableDiscoveryClient// 开启服务发现
+@SpringBootApplication
+public class Cloud1Application {
+ public static void main(String[] args) {
+ SpringApplication.run(Cloud1Application.class, args);
+ }
+}
\ No newline at end of file
diff --git a/service/cloud-demo1/src/main/java/cn/bunny/config/CloudConfiguration.java b/service/cloud-demo1/src/main/java/cn/bunny/config/CloudConfiguration.java
new file mode 100644
index 0000000..76ed863
--- /dev/null
+++ b/service/cloud-demo1/src/main/java/cn/bunny/config/CloudConfiguration.java
@@ -0,0 +1,16 @@
+package cn.bunny.config;
+
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+@Configuration
+public class CloudConfiguration {
+
+ @Bean
+ @LoadBalanced// 负载均衡
+ public RestTemplate restTemplate() {
+ return new RestTemplate();
+ }
+}
diff --git a/service/cloud-demo1/src/main/resources/application-dev.yml b/service/cloud-demo1/src/main/resources/application-dev.yml
new file mode 100644
index 0000000..e69de29
diff --git a/service/cloud-demo1/src/main/resources/application.yml b/service/cloud-demo1/src/main/resources/application.yml
new file mode 100644
index 0000000..19f9ac6
--- /dev/null
+++ b/service/cloud-demo1/src/main/resources/application.yml
@@ -0,0 +1,10 @@
+server:
+ port: 8000
+
+spring:
+ application:
+ name: cloud-demo1
+
+ cloud:
+ nacos:
+ server-addr: 192.168.3.132
\ No newline at end of file
diff --git a/service/cloud-demo1/src/test/java/cn/bunny/AppTest.java b/service/cloud-demo1/src/test/java/cn/bunny/AppTest.java
new file mode 100644
index 0000000..34b54ff
--- /dev/null
+++ b/service/cloud-demo1/src/test/java/cn/bunny/AppTest.java
@@ -0,0 +1,38 @@
+package cn.bunny;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public AppTest( String testName )
+ {
+ super( testName );
+ }
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ return new TestSuite( AppTest.class );
+ }
+
+ /**
+ * Rigourous Test :-)
+ */
+ public void testApp()
+ {
+ assertTrue( true );
+ }
+}
diff --git a/service/cloud-demo2/pom.xml b/service/cloud-demo2/pom.xml
new file mode 100644
index 0000000..01ae6dc
--- /dev/null
+++ b/service/cloud-demo2/pom.xml
@@ -0,0 +1,23 @@
+
+ 4.0.0
+
+ cn.bunny
+ service
+ 0.0.1-SNAPSHOT
+
+
+ cloud-demo2
+ jar
+
+ cloud-demo2
+ https://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+
+
diff --git a/service/cloud-demo2/src/main/java/cn/bunny/Cloud2Application.java b/service/cloud-demo2/src/main/java/cn/bunny/Cloud2Application.java
new file mode 100644
index 0000000..f10a3af
--- /dev/null
+++ b/service/cloud-demo2/src/main/java/cn/bunny/Cloud2Application.java
@@ -0,0 +1,13 @@
+package cn.bunny;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+
+@EnableDiscoveryClient
+@SpringBootApplication
+public class Cloud2Application {
+ public static void main(String[] args) {
+ SpringApplication.run(Cloud2Application.class, args);
+ }
+}
diff --git a/service/cloud-demo2/src/main/java/cn/bunny/config/CloudConfiguration.java b/service/cloud-demo2/src/main/java/cn/bunny/config/CloudConfiguration.java
new file mode 100644
index 0000000..af8145c
--- /dev/null
+++ b/service/cloud-demo2/src/main/java/cn/bunny/config/CloudConfiguration.java
@@ -0,0 +1,16 @@
+package cn.bunny.config;
+
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+@Configuration
+public class CloudConfiguration {
+
+ @Bean
+ @LoadBalanced
+ public RestTemplate restTemplate() {
+ return new RestTemplate();
+ }
+}
diff --git a/service/cloud-demo2/src/main/resources/application.yml b/service/cloud-demo2/src/main/resources/application.yml
new file mode 100644
index 0000000..031503e
--- /dev/null
+++ b/service/cloud-demo2/src/main/resources/application.yml
@@ -0,0 +1,9 @@
+server:
+ port: 8001
+spring:
+ application:
+ name: cloud-demo2
+
+ cloud:
+ nacos:
+ server-addr: 192.168.3.132
diff --git a/service/cloud-demo2/src/test/java/cn/bunny/AppTest.java b/service/cloud-demo2/src/test/java/cn/bunny/AppTest.java
new file mode 100644
index 0000000..34b54ff
--- /dev/null
+++ b/service/cloud-demo2/src/test/java/cn/bunny/AppTest.java
@@ -0,0 +1,38 @@
+package cn.bunny;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public AppTest( String testName )
+ {
+ super( testName );
+ }
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ return new TestSuite( AppTest.class );
+ }
+
+ /**
+ * Rigourous Test :-)
+ */
+ public void testApp()
+ {
+ assertTrue( true );
+ }
+}
diff --git a/service/pom.xml b/service/pom.xml
new file mode 100644
index 0000000..62cd280
--- /dev/null
+++ b/service/pom.xml
@@ -0,0 +1,69 @@
+
+ 4.0.0
+
+ cn.bunny
+ cloud1
+ 0.0.1-SNAPSHOT
+
+
+ service
+ pom
+
+ cloud-demo1
+ cloud-demo2
+
+ service
+ https://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.projectlombok
+ lombok
+ annotationProcessor
+
+
+ io.projectreactor
+ reactor-test
+ test
+
+
+
+ junit
+ junit
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+