Commit 9fffa681 by ethanlamzs

测试 spring_boot + dubbo 的融合

1 parent 7739ad07
...@@ -7,7 +7,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -7,7 +7,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class DemoDubboSpringBootStartApplication { public class DemoDubboSpringBootStartApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DemoDubboSpringBootStartApplication.class, args); SpringApplication.run(DemoDubboSpringBootStartApplication.class, args);
try {
System.in.read();
} catch (Exception e) {
e.printStackTrace();
}
} }
......
...@@ -4,7 +4,7 @@ server.port = 9090 ...@@ -4,7 +4,7 @@ server.port = 9090
management.port = 9091 management.port = 9091
# Base packages to scan Dubbo Components (e.g., @Service, @Reference) # Base packages to scan Dubbo Components (e.g., @Service, @Reference)
dubbo.scan.basePackages = com.alibaba.boot.dubbo.demo.provider.service dubbo.scan.basePackages = com.zhzf.fpj.xcx.demodubbospringbootstart.service
# Dubbo Config properties # Dubbo Config properties
## ApplicationConfig Bean ## ApplicationConfig Bean
......
<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.zhzf.fpj.xcx</groupId>
<artifactId>fpj-xcx</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>core-webs</artifactId>
<name>core-webs</name>
<description>core-webs 所有的外部项目</description>
<packaging>pom</packaging>
<properties>
<javax.servlet.version>3.1.0</javax.servlet.version>
</properties>
<modules>
<module>web-demo</module>
</modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<scope>true</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax.servlet.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file \ No newline at end of file
<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.zhzf.fpj.xcx</groupId>
<artifactId>core-webs</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>web-demo</artifactId>
<name>web-demo</name>
<description>core-web-demo</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.zhzf.fpj.xcx.demodubbospringbootstart;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = "com.zhzf.fpj.xcx.web.controller")
public class DemoDubboSpringBootStartApplication {
public static void main(String[] args) {
SpringApplication.run(DemoDubboSpringBootStartApplication.class, args);
}
}
package com.zhzf.fpj.xcx.web.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.zhzf.fpj.xcx.demo.DemoService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DemoConsumerController {
@Reference(version = "1.0.0",
application = "${dubbo.application.id}",
url = "dubbo://localhost:12345")
private DemoService demoService;
@RequestMapping("/sayHello")
public String sayHello(@RequestParam String name) {
return demoService.sayHello(name);
}
}
# Spring boot application
spring.application.name = dubbo-consumer-demo
server.port = 8080
management.port = 8081
# Dubbo Config properties
## ApplicationConfig Bean
dubbo.application.id = dubbo-consumer-demo
dubbo.application.name = dubbo-consumer-demo
## ProtocolConfig Bean
dubbo.protocol.id = dubbo
dubbo.protocol.name = dubbo
dubbo.protocol.port = 12345
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<!--module>core-common</module--> <!--module>core-common</module-->
<!--module>core-domains</module--> <!--module>core-domains</module-->
<module>core-services</module> <module>core-services</module>
<!--module>core-web</module--> <module>core-webs</module>
</modules> </modules>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!