Skip to content

Commit 4cadcb6

Browse files
authored
0.2.1 (#357)
* Fix #169 * Polish : #324 & #325 * Polish : #315 * Polish : #321 * Polish : #321 * Polish : #321 for test case * Polish : Update Demos * Polish : Update version to be 0.2.1 * Polish : #319 * Polish : #226 * Polish : #309 * Fix the test case's bugs * Fix the test case's bugs * Fix a JavaDoc issue * Update SNAPSHOT and add exclude list * Update SNAPSHOT to be 0.2.1-SNAPSHOT * Update JDK versions * Update JDK versions * Reactor & remove author info * Refactor : to save a shutdown hook thread * Remove javax.servlet:javax.servlet-api:3.1.0 that may cause class conflict, and use indirectly dependencies from spring-boot-starter-* * Polish #341 * Add the samples * Add a license
1 parent 7021e60 commit 4cadcb6

File tree

22 files changed

+436
-216
lines changed

22 files changed

+436
-216
lines changed

dubbo-spring-boot-autoconfigure/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
<artifactId>dubbo-spring-boot-autoconfigure</artifactId>
2929
<packaging>jar</packaging>
30-
<name>Dubbo Spring Boot AutoConfigure</name>
31-
<description>Dubbo Spring Boot AutoConfigure</description>
30+
<name>Dubbo Spring Boot Auto-Configure</name>
31+
<description>Dubbo Spring Boot Auto-Configure</description>
3232

3333

3434
<dependencies>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xmlns="http://maven.apache.org/POM/4.0.0"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<parent>
21+
<groupId>com.alibaba.boot.samples</groupId>
22+
<artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
23+
<version>0.2.1-SNAPSHOT</version>
24+
<relativePath>../pom.xml</relativePath>
25+
</parent>
26+
<modelVersion>4.0.0</modelVersion>
27+
28+
<artifactId>dubbo-spring-boot-auto-configure-consumer-sample</artifactId>
29+
<name>Dubbo Spring Boot Samples : Auto-Configure :: Consumer Sample</name>
30+
<dependencies>
31+
32+
<!-- Spring Boot dependencies -->
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter</artifactId>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>com.alibaba.boot</groupId>
40+
<artifactId>dubbo-spring-boot-starter</artifactId>
41+
<version>${project.version}</version>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>com.alibaba</groupId>
46+
<artifactId>dubbo</artifactId>
47+
</dependency>
48+
49+
<dependency>
50+
<groupId>${project.groupId}</groupId>
51+
<artifactId>dubbo-spring-boot-sample-api</artifactId>
52+
<version>${project.version}</version>
53+
</dependency>
54+
55+
</dependencies>
56+
57+
<build>
58+
<plugins>
59+
<plugin>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-maven-plugin</artifactId>
62+
<version>${spring-boot.version}</version>
63+
<executions>
64+
<execution>
65+
<goals>
66+
<goal>repackage</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
74+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.alibaba.boot.dubbo.demo.consumer.bootstrap;
18+
19+
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
20+
import com.alibaba.dubbo.config.annotation.Reference;
21+
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
24+
import org.springframework.boot.ApplicationRunner;
25+
import org.springframework.boot.SpringApplication;
26+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
27+
import org.springframework.context.annotation.Bean;
28+
29+
/**
30+
* Dubbo Auto Configuration Consumer Bootstrap
31+
*
32+
* @since 1.0.0
33+
*/
34+
@EnableAutoConfiguration
35+
public class DubboAutoConfigurationConsumerBootstrap {
36+
37+
private final Logger logger = LoggerFactory.getLogger(getClass());
38+
39+
@Reference(version = "1.0.0", url = "dubbo://localhost:12345")
40+
private DemoService demoService;
41+
42+
@Bean
43+
public ApplicationRunner runner() {
44+
return args -> {
45+
logger.info(demoService.sayHello("mercyblitz"));
46+
};
47+
}
48+
49+
public static void main(String[] args) {
50+
SpringApplication.run(DubboAutoConfigurationConsumerBootstrap.class).close();
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
spring:
2+
application:
3+
name: dubbo-auto-configure-consumer-sample
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xmlns="http://maven.apache.org/POM/4.0.0"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<parent>
21+
<groupId>com.alibaba.boot.samples</groupId>
22+
<artifactId>dubbo-spring-boot-samples</artifactId>
23+
<version>0.2.1-SNAPSHOT</version>
24+
<relativePath>../pom.xml</relativePath>
25+
</parent>
26+
<modelVersion>4.0.0</modelVersion>
27+
28+
<artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
29+
<name>Dubbo Spring Boot Samples : Auto-Configure</name>
30+
<description>Dubbo Spring Boot Auto-Configure Samples</description>
31+
<packaging>pom</packaging>
32+
33+
<modules>
34+
<module>consumer-sample</module>
35+
<module>provider-sample</module>
36+
</modules>
37+
38+
</project>

dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml renamed to dubbo-spring-boot-samples/auto-configure-samples/provider-sample/pom.xml

+9-19
Original file line numberDiff line numberDiff line change
@@ -14,42 +14,31 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<project xmlns="http://maven.apache.org/POM/4.0.0"
18-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xmlns="http://maven.apache.org/POM/4.0.0"
1919
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2020
<parent>
21-
<groupId>com.alibaba.boot</groupId>
22-
<artifactId>dubbo-spring-boot-samples</artifactId>
21+
<groupId>com.alibaba.boot.samples</groupId>
22+
<artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
2323
<version>0.2.1-SNAPSHOT</version>
2424
<relativePath>../pom.xml</relativePath>
2525
</parent>
2626
<modelVersion>4.0.0</modelVersion>
2727

28-
<artifactId>dubbo-spring-boot-sample-consumer</artifactId>
29-
<name>Dubbo Spring Boot Sample : Consumer</name>
28+
<artifactId>dubbo-spring-boot-auto-configure-provider-sample</artifactId>
29+
<name>Dubbo Spring Boot Samples : Auto-Configure :: Provider Sample</name>
3030

3131
<dependencies>
3232

3333
<!-- Spring Boot dependencies -->
3434
<dependency>
3535
<groupId>org.springframework.boot</groupId>
36-
<artifactId>spring-boot-starter-web</artifactId>
37-
</dependency>
38-
39-
<dependency>
40-
<groupId>org.springframework.boot</groupId>
41-
<artifactId>spring-boot-starter-actuator</artifactId>
42-
</dependency>
43-
44-
<dependency>
45-
<groupId>${project.groupId}</groupId>
46-
<artifactId>dubbo-spring-boot-starter</artifactId>
47-
<version>${project.version}</version>
36+
<artifactId>spring-boot-starter</artifactId>
4837
</dependency>
4938

5039
<dependency>
5140
<groupId>com.alibaba.boot</groupId>
52-
<artifactId>dubbo-spring-boot-actuator</artifactId>
41+
<artifactId>dubbo-spring-boot-starter</artifactId>
5342
<version>${project.version}</version>
5443
</dependency>
5544

@@ -83,4 +72,5 @@
8372
</plugins>
8473
</build>
8574

75+
8676
</project>
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,23 @@
1717
package com.alibaba.boot.dubbo.demo.provider.bootstrap;
1818

1919
import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
20+
2021
import org.springframework.boot.WebApplicationType;
21-
import org.springframework.boot.autoconfigure.SpringBootApplication;
22+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2223
import org.springframework.boot.builder.SpringApplicationBuilder;
2324

2425
/**
25-
* Dubbo Provider Demo
26+
* Dubbo Auto-Configuration Provider Bootstrap
2627
*
27-
* @author <a href="mailto:[email protected]">Mercy</a>
2828
* @see DefaultDemoService
2929
* @since 1.0.0
3030
*/
31-
@SpringBootApplication
32-
public class DubboProviderDemo {
31+
@EnableAutoConfiguration
32+
public class DubboAutoConfigurationProviderBootstrap {
3333

3434
public static void main(String[] args) {
35-
36-
new SpringApplicationBuilder(DubboProviderDemo.class)
35+
new SpringApplicationBuilder(DubboAutoConfigurationProviderBootstrap.class)
3736
.web(WebApplicationType.NONE)
3837
.run(args);
39-
4038
}
41-
4239
}
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,24 @@
1919
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
2020
import com.alibaba.dubbo.config.annotation.Service;
2121

22-
import javax.ws.rs.GET;
23-
import javax.ws.rs.Path;
24-
import javax.ws.rs.QueryParam;
22+
import org.springframework.beans.factory.annotation.Value;
2523

2624
/**
2725
* Default {@link DemoService}
2826
*
29-
* @author <a href="mailto:[email protected]">Mercy</a>
3027
* @see DemoService
3128
* @since 1.0.0
3229
*/
33-
@Service(
34-
version = "${demo.service.version}",
35-
protocol = {"dubbo", "rest"},
36-
registry = "${dubbo.registry.id}"
37-
)
38-
@Path("demo")
30+
@Service(version = "1.0.0")
3931
public class DefaultDemoService implements DemoService {
4032

41-
@GET
42-
@Path("/say-hello")
43-
public String sayHello(@QueryParam("name") String name) {
44-
return "Hello, " + name + " (from Spring Boot)";
33+
/**
34+
* The default value of ${dubbo.application.name} is ${spring.application.name}
35+
*/
36+
@Value("${dubbo.application.name}")
37+
private String serviceName;
38+
39+
public String sayHello(String name) {
40+
return String.format("[%s] : Hello, %s", serviceName, name);
4541
}
4642
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Spring boot application
2+
spring.application.name=dubbo-auto-configuration-provider-demo
3+
# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
4+
dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
5+
# Dubbo Application
6+
## The default value of dubbo.application.name is ${spring.application.name}
7+
## dubbo.application.name=${spring.application.name}
8+
# Dubbo Protocol
9+
dubbo.protocol.name=dubbo
10+
dubbo.protocol.port=12345
11+
## Dubbo Registry
12+
dubbo.registry.address=N/A

dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.yml

-37
This file was deleted.

0 commit comments

Comments
 (0)