You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by il...@apache.org on 2019/04/30 06:10:11 UTC
[incubator-dubbo-samples] branch master updated: #70: Failed to run
dubbo-sample-annotation
This is an automated email from the ASF dual-hosted git repository.
iluo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new beafe5c #70: Failed to run dubbo-sample-annotation
beafe5c is described below
commit beafe5c403d366d5b791f128143de4625aa77e8a
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Tue Apr 30 14:09:40 2019 +0800
#70: Failed to run dubbo-sample-annotation
---
dubbo-samples-annotation/pom.xml | 286 +--------------------
.../samples/annotation/AnnotationConstants.java | 5 +-
.../annotation/AnnotationConsumerBootstrap.java | 6 +-
.../annotation/AnnotationProviderBootstrap.java | 5 +-
.../annotation/action/AnnotationAction.java | 19 +-
.../samples/annotation/api/GreetingService.java | 34 +++
.../HelloService.java} | 29 +--
.../impl/AnnotationGreetingServiceImpl.java | 5 +-
.../impl/AnnotationHelloServiceImpl.java | 11 +-
9 files changed, 62 insertions(+), 338 deletions(-)
diff --git a/dubbo-samples-annotation/pom.xml b/dubbo-samples-annotation/pom.xml
index 58d9b65..20012f8 100644
--- a/dubbo-samples-annotation/pom.xml
+++ b/dubbo-samples-annotation/pom.xml
@@ -27,210 +27,29 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>dubbo-samples-annotation</artifactId>
+
<properties>
<source.level>1.8</source.level>
<target.level>1.8</target.level>
- <spring.version>4.3.16.RELEASE</spring.version>
- <dubbo.version>2.7.0</dubbo.version>
- <dubbo.rpc.version>2.7.0</dubbo.rpc.version>
- <zookeeper.version>3.4.13</zookeeper.version>
- <curator.version>4.0.1</curator.version>
- <validation-api.version>1.1.0.Final</validation-api.version>
- <hibernate-validator.version>4.2.0.Final</hibernate-validator.version>
- <resteasy.version>3.0.19.Final</resteasy.version>
- <curator-client.version>4.0.1</curator-client.version>
- <swagger.version>1.5.19</swagger.version>
- <tomcat.version>7.0.88</tomcat.version>
- <servlet.version>3.0.1</servlet.version>
- <maven_checkstyle_version>3.0.0</maven_checkstyle_version>
- <apache-rat-plugin.version>0.12</apache-rat-plugin.version>
- <spring-boot.version>1.5.13.RELEASE</spring-boot.version>
+ <dubbo.version>2.7.1</dubbo.version>
</properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-framework-bom</artifactId>
- <version>${spring.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <!-- Import dependency management from Spring Boot -->
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>${spring-boot.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>4.1.16.Final</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-bom</artifactId>
- <version>${dubbo.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo</artifactId>
- <version>${dubbo.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.thrift</groupId>
- <artifactId>libthrift</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-rest</artifactId>
- <version>${dubbo.rpc.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${zookeeper.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.validation</groupId>
- <artifactId>validation-api</artifactId>
- <version>${validation-api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>${hibernate-validator.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jackson-provider</artifactId>
- <version>${resteasy.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-client</artifactId>
- <version>${curator-client.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>${servlet.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-core</artifactId>
- <version>${tomcat.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-logging-juli</artifactId>
- <version>${tomcat.version}</version>
- </dependency>
- <!-- swagger -->
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-annotations</artifactId>
- <version>${swagger.version}</version>
- </dependency>
- <dependency>
- <groupId>io.swagger</groupId>
- <artifactId>swagger-jaxrs</artifactId>
- <version>${swagger.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <exclusions>
- <exclusion>
- <groupId>io.netty</groupId>
- <artifactId>netty</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
</dependency>
+
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-configcenter-zookeeper</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- </dependency>
- <!-- Remove this dependency whenever -->
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-metadata-report-api</artifactId>
- </dependency>
- <dependency>
- <groupId>com.alibaba.spring</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>1.0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-samples-api-client</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
</dependency>
</dependencies>
-
-
<build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot.version}</version>
- </plugin>
- </plugins>
- </pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -241,97 +60,6 @@
<target>${target.level}</target>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <version>${apache-rat-plugin.version}</version>
- <executions>
- <execution>
- <id>verify.rat</id>
- <phase>verify</phase>
- <goals>
- <goal>check</goal>
- </goals>
- <configuration>
- <excludes>
- <exclude>**/*.versionsBackup</exclude>
- <exclude>**/.idea/</exclude>
- <exclude>**/*.iml</exclude>
- <exclude>**/*.txt</exclude>
- <exclude>**/*.load</exclude>
- <exclude>**/*.flex</exclude>
- <exclude>**/*.fc</exclude>
- <exclude>**/*.javascript</exclude>
- <exclude>**/*.properties</exclude>
- <exclude>**/*.thrift</exclude>
- <exclude>**/*.sh</exclude>
- <exclude>**/*.bat</exclude>
- <exclude>**/*.md</exclude>
- <exclude>.git/</exclude>
- <exclude>.gitignore</exclude>
- <!-- ASF jenkins box puts the Maven repo in our root directory. -->
- <exclude>.repository/</exclude>
- <exclude>**/.settings/*</exclude>
- <exclude>**/.classpath</exclude>
- <exclude>**/.project</exclude>
- <exclude>**/target/**</exclude>
- <exclude>**/*.log</exclude>
- <exclude>CODE_OF_CONDUCT.md</exclude>
- <exclude>.codecov.yml</exclude>
- <exclude>.travis.yml</exclude>
- <exclude>PULL_REQUEST_TEMPLATE.md</exclude>
- <exclude>CONTRIBUTING.md</exclude>
- <exclude>README.md</exclude>
- <exclude>**/codestyle/*</exclude>
- <exclude>**/resources/META-INF/**</exclude>
- <exclude>**/webapp/swagger/**</exclude>
- <exclude>**/org/apache/dubbo/samples/rpc/nativethrift/api/DemoService.java</exclude>
- </excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
-
- <profiles>
- <profile>
- <id>checkstyle</id>
- <activation>
- <jdk>[1.8,)</jdk>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>${maven_checkstyle_version}</version>
- <dependencies>
- <dependency>
- <groupId>com.puppycrawl.tools</groupId>
- <artifactId>checkstyle</artifactId>
- <version>8.9</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>checkstyle-validation</id>
- <phase>validate</phase>
- <configuration>
- <configLocation>../codestyle/checkstyle.xml</configLocation>
- <suppressionsLocation>../codestyle/checkstyle-suppressions.xml</suppressionsLocation>
- <encoding>UTF-8</encoding>
- <consoleOutput>true</consoleOutput>
- <failOnViolation>true</failOnViolation>
- </configuration>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
</project>
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationConstants.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationConstants.java
index 678805b..f2268b8 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationConstants.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationConstants.java
@@ -18,9 +18,6 @@
*/
package org.apache.dubbo.samples.annotation;
-/**
- * @author cvictory ON 2019-03-12
- */
public interface AnnotationConstants {
- static final String VERSION = "1.0.0_annotation";
+ String VERSION = "1.0.0_annotation";
}
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationConsumerBootstrap.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationConsumerBootstrap.java
index 6159d2b..7c483d9 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationConsumerBootstrap.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationConsumerBootstrap.java
@@ -27,12 +27,9 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
-/**
- * CallbackConsumer
- */
public class AnnotationConsumerBootstrap {
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
context.start();
final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction");
@@ -41,7 +38,6 @@ public class AnnotationConsumerBootstrap {
System.out.println("goodbye :" + annotationAction.doSayGoodbye("world"));
System.out.println("greeting :" + annotationAction.doGreeting("world"));
System.out.println("reply :" + annotationAction.replyGreeting("world"));
- System.in.read();
}
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationProviderBootstrap.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationProviderBootstrap.java
index ec46463..e5f7858 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationProviderBootstrap.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/AnnotationProviderBootstrap.java
@@ -28,13 +28,12 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
-/**
- * MergeProvider
- */
public class AnnotationProviderBootstrap {
public static void main(String[] args) throws Exception {
new EmbeddedZooKeeper(2181, false).start();
+ Thread.sleep(1000);
+
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
context.start();
System.in.read();
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/action/AnnotationAction.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/action/AnnotationAction.java
index 365a8e3..0c9c61e 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/action/AnnotationAction.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/action/AnnotationAction.java
@@ -19,26 +19,23 @@
package org.apache.dubbo.samples.annotation.action;
+import org.apache.dubbo.config.annotation.Method;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.samples.annotation.AnnotationConstants;
-import org.apache.dubbo.samples.api.client.GreetingService;
-import org.apache.dubbo.samples.api.client.HelloService;
+import org.apache.dubbo.samples.annotation.api.GreetingService;
+import org.apache.dubbo.samples.annotation.api.HelloService;
import org.springframework.stereotype.Component;
-/**
- * AnnotationAction
- */
@Component("annotationAction")
public class AnnotationAction {
@Reference(interfaceClass = HelloService.class, version = AnnotationConstants.VERSION)
private HelloService helloService;
- /**
- * @since 2.7.1
- */
- //@Reference(interfaceClass = GreetingService.class, version = AnnotationConstants.VERSION, methods = {@Method(name = "greeting", timeout = 250, retries = 1)})
+ @Reference(interfaceClass = GreetingService.class,
+ version = AnnotationConstants.VERSION,
+ methods = {@Method(name = "greeting", timeout = 250, retries = 1)})
private GreetingService greetingService;
public String doSayHello(String name) {
@@ -51,7 +48,6 @@ public class AnnotationAction {
}
public String doSayGoodbye(String name) {
-
try {
return helloService.sayGoodbye(name);
} catch (Exception e) {
@@ -62,7 +58,6 @@ public class AnnotationAction {
}
public String doGreeting(String name) {
-
try {
return greetingService.greeting(name);
} catch (Exception e) {
@@ -79,7 +74,5 @@ public class AnnotationAction {
e.printStackTrace();
return "Throw Exception";
}
-
}
-
}
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/api/GreetingService.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/api/GreetingService.java
new file mode 100644
index 0000000..f2cbc8c
--- /dev/null
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/api/GreetingService.java
@@ -0,0 +1,34 @@
+/*
+ * 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 org.apache.dubbo.samples.annotation.api;
+
+import java.util.concurrent.CompletableFuture;
+
+public interface GreetingService {
+
+ String greeting(String name);
+
+ default String replyGreeting(String name) {
+ return "Fine, " + name;
+ }
+
+ default CompletableFuture<String> greeting(String name, byte signal) {
+ return CompletableFuture.completedFuture(greeting(name));
+ }
+
+}
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationHelloServiceImpl.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/api/HelloService.java
similarity index 50%
copy from dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationHelloServiceImpl.java
copy to dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/api/HelloService.java
index fe4146d..f2bdb75 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationHelloServiceImpl.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/api/HelloService.java
@@ -14,35 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.annotation.impl;
-import org.apache.dubbo.samples.api.client.HelloService;
+package org.apache.dubbo.samples.annotation.api;
-/**
- * @since 2.7.1
- */
-//@Service(version = AnnotationConstants.VERSION, methods = {@Method(name = "sayGoodbye", timeout = 250, retries = 0)})
-public class AnnotationHelloServiceImpl implements HelloService {
+public interface HelloService {
- @Override
- public String sayHello(String name) {
- System.out.println("provider received invoke of sayHello: " + name);
- sleepWhile();
- return "Annotation, hello " + name;
- }
+ String sayHello(String name);
- public String sayGoodbye(String name) {
- System.out.println("provider received invoke of sayGoodbye: " + name);
- sleepWhile();
+ default String sayGoodbye(String name) {
return "Goodbye, " + name;
}
-
- private void sleepWhile() {
- try {
- Thread.sleep(300);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
}
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationGreetingServiceImpl.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationGreetingServiceImpl.java
index e869660..d9c7489 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationGreetingServiceImpl.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationGreetingServiceImpl.java
@@ -18,11 +18,8 @@ package org.apache.dubbo.samples.annotation.impl;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.samples.annotation.AnnotationConstants;
-import org.apache.dubbo.samples.api.client.GreetingService;
+import org.apache.dubbo.samples.annotation.api.GreetingService;
-/**
- * 2019-03-12
- */
@Service(version = AnnotationConstants.VERSION)
public class AnnotationGreetingServiceImpl implements GreetingService {
diff --git a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationHelloServiceImpl.java b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationHelloServiceImpl.java
index fe4146d..b0e0f92 100644
--- a/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationHelloServiceImpl.java
+++ b/dubbo-samples-annotation/src/main/java/org/apache/dubbo/samples/annotation/impl/AnnotationHelloServiceImpl.java
@@ -16,12 +16,13 @@
*/
package org.apache.dubbo.samples.annotation.impl;
-import org.apache.dubbo.samples.api.client.HelloService;
-/**
- * @since 2.7.1
- */
-//@Service(version = AnnotationConstants.VERSION, methods = {@Method(name = "sayGoodbye", timeout = 250, retries = 0)})
+import org.apache.dubbo.config.annotation.Method;
+import org.apache.dubbo.config.annotation.Service;
+import org.apache.dubbo.samples.annotation.AnnotationConstants;
+import org.apache.dubbo.samples.annotation.api.HelloService;
+
+@Service(version = AnnotationConstants.VERSION, methods = {@Method(name = "sayGoodbye", timeout = 250, retries = 0)})
public class AnnotationHelloServiceImpl implements HelloService {
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org