-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
1 parent
7021e60
commit 4cadcb6
Showing
22 changed files
with
436 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>com.alibaba.boot.samples</groupId> | ||
<artifactId>dubbo-spring-boot-auto-configure-samples</artifactId> | ||
<version>0.2.1-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>dubbo-spring-boot-auto-configure-consumer-sample</artifactId> | ||
<name>Dubbo Spring Boot Samples : Auto-Configure :: Consumer Sample</name> | ||
<dependencies> | ||
|
||
<!-- Spring Boot dependencies --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba.boot</groupId> | ||
<artifactId>dubbo-spring-boot-starter</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>dubbo</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>dubbo-spring-boot-sample-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>${spring-boot.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
52 changes: 52 additions & 0 deletions
52
...m/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.alibaba.boot.dubbo.demo.consumer.bootstrap; | ||
|
||
import com.alibaba.boot.dubbo.demo.consumer.DemoService; | ||
import com.alibaba.dubbo.config.annotation.Reference; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.ApplicationRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
/** | ||
* Dubbo Auto Configuration Consumer Bootstrap | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
@EnableAutoConfiguration | ||
public class DubboAutoConfigurationConsumerBootstrap { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@Reference(version = "1.0.0", url = "dubbo://localhost:12345") | ||
private DemoService demoService; | ||
|
||
@Bean | ||
public ApplicationRunner runner() { | ||
return args -> { | ||
logger.info(demoService.sayHello("mercyblitz")); | ||
}; | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(DubboAutoConfigurationConsumerBootstrap.class).close(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ng-boot-samples/auto-configure-samples/consumer-sample/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
spring: | ||
application: | ||
name: dubbo-auto-configure-consumer-sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>com.alibaba.boot.samples</groupId> | ||
<artifactId>dubbo-spring-boot-samples</artifactId> | ||
<version>0.2.1-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>dubbo-spring-boot-auto-configure-samples</artifactId> | ||
<name>Dubbo Spring Boot Samples : Auto-Configure</name> | ||
<description>Dubbo Spring Boot Auto-Configure Samples</description> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>consumer-sample</module> | ||
<module>provider-sample</module> | ||
</modules> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,26 +17,23 @@ | |
package com.alibaba.boot.dubbo.demo.provider.bootstrap; | ||
|
||
import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService; | ||
|
||
import org.springframework.boot.WebApplicationType; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
|
||
/** | ||
* Dubbo Provider Demo | ||
* Dubbo Auto-Configuration Provider Bootstrap | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy</a> | ||
* @see DefaultDemoService | ||
* @since 1.0.0 | ||
*/ | ||
@SpringBootApplication | ||
public class DubboProviderDemo { | ||
@EnableAutoConfiguration | ||
public class DubboAutoConfigurationProviderBootstrap { | ||
|
||
public static void main(String[] args) { | ||
|
||
new SpringApplicationBuilder(DubboProviderDemo.class) | ||
new SpringApplicationBuilder(DubboAutoConfigurationProviderBootstrap.class) | ||
.web(WebApplicationType.NONE) | ||
.run(args); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,28 +19,24 @@ | |
import com.alibaba.boot.dubbo.demo.consumer.DemoService; | ||
import com.alibaba.dubbo.config.annotation.Service; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.QueryParam; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
/** | ||
* Default {@link DemoService} | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy</a> | ||
* @see DemoService | ||
* @since 1.0.0 | ||
*/ | ||
@Service( | ||
version = "${demo.service.version}", | ||
protocol = {"dubbo", "rest"}, | ||
registry = "${dubbo.registry.id}" | ||
) | ||
@Path("demo") | ||
@Service(version = "1.0.0") | ||
public class DefaultDemoService implements DemoService { | ||
|
||
@GET | ||
@Path("/say-hello") | ||
public String sayHello(@QueryParam("name") String name) { | ||
return "Hello, " + name + " (from Spring Boot)"; | ||
/** | ||
* The default value of ${dubbo.application.name} is ${spring.application.name} | ||
*/ | ||
@Value("${dubbo.application.name}") | ||
private String serviceName; | ||
|
||
public String sayHello(String name) { | ||
return String.format("[%s] : Hello, %s", serviceName, name); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...-samples/auto-configure-samples/provider-sample/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Spring boot application | ||
spring.application.name=dubbo-auto-configuration-provider-demo | ||
# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service | ||
dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service | ||
# Dubbo Application | ||
## The default value of dubbo.application.name is ${spring.application.name} | ||
## dubbo.application.name=${spring.application.name} | ||
# Dubbo Protocol | ||
dubbo.protocol.name=dubbo | ||
dubbo.protocol.port=12345 | ||
## Dubbo Registry | ||
dubbo.registry.address=N/A |
37 changes: 0 additions & 37 deletions
37
...-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.yml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.