testMybatis(String text) {
+ return testService.testMybatis(text);
+ }
}
diff --git a/dubbo-core/pom.xml b/dubbo-core/pom.xml
new file mode 100644
index 0000000..28e1ab4
--- /dev/null
+++ b/dubbo-core/pom.xml
@@ -0,0 +1,71 @@
+
+
+ 4.0.0
+
+ dubbo-core
+ 0.0.1-SNAPSHOT
+ jar
+
+
+ com.coderqian
+ dubbo-spring-boot-cli
+ 1.0-SNAPSHOT
+
+
+ dubbo-core
+ Demo project for Spring Boot
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 1.3.2
+
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ 1.1.10
+
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.0
+ provided
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ exec
+
+
+
+
+
+
diff --git a/dubbo-core/src/main/java/com/coderqian/dubbocore/DubboCoreApplication.java b/dubbo-core/src/main/java/com/coderqian/dubbocore/DubboCoreApplication.java
new file mode 100644
index 0000000..907de47
--- /dev/null
+++ b/dubbo-core/src/main/java/com/coderqian/dubbocore/DubboCoreApplication.java
@@ -0,0 +1,16 @@
+package com.coderqian.dubbocore;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@MapperScan("com.coderqian.dubbocore.mapper")
+public class DubboCoreApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboCoreApplication.class, args);
+ }
+
+}
+
diff --git a/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/config/DruidDBConfig.java b/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/config/DruidDBConfig.java
new file mode 100644
index 0000000..0494b93
--- /dev/null
+++ b/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/config/DruidDBConfig.java
@@ -0,0 +1,54 @@
+package com.coderqian.dubbocore.configuration.config;
+
+import com.alibaba.druid.pool.DruidDataSource;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.sql.DataSource;
+
+/**
+ * @author qianliqing
+ * @date 2019/1/18 6:52 PM
+ * email: qianlq0824@gmail.com
+ */
+
+@Configuration
+public class DruidDBConfig {
+
+ @Value("${spring.datasource.url}")
+ private String dbUrl;
+
+ @Value("${spring.datasource.username}")
+ private String username;
+
+ @Value("${spring.datasource.password}")
+ private String password;
+
+ @Value("${spring.datasource.driver-class-name}")
+ private String driverClassName;
+
+ @Value("${spring.datasource.initialSize}")
+ private int initialSize;
+
+ @Value("${spring.datasource.minIdle}")
+ private int minIdle;
+
+ @Value("${spring.datasource.maxActive}")
+ private int maxActive;
+
+ @Bean
+ @Primary
+ public DataSource dataSource() {
+ DruidDataSource datasource = new DruidDataSource();
+ datasource.setUrl(dbUrl);
+ datasource.setUsername(username);
+ datasource.setPassword(password);
+ datasource.setDriverClassName(driverClassName);
+ datasource.setInitialSize(initialSize);
+ datasource.setMinIdle(minIdle);
+ datasource.setMaxActive(maxActive);
+ return datasource;
+ }
+}
diff --git a/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/filter/DruidStatFilter.java b/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/filter/DruidStatFilter.java
new file mode 100644
index 0000000..970c478
--- /dev/null
+++ b/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/filter/DruidStatFilter.java
@@ -0,0 +1,21 @@
+package com.coderqian.dubbocore.configuration.filter;
+
+import com.alibaba.druid.support.http.WebStatFilter;
+
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.annotation.WebInitParam;
+
+/**
+ * @author qianliqing
+ * @date 2019-01-18 6:37 PM
+ * mail: qianlq0824@gmail.com
+ *
+ * 配置druid监控统计功能和过滤器
+ */
+@WebFilter(filterName = "druidWebStatFilter", urlPatterns = "/*",
+ initParams = {
+ @WebInitParam(name = "exclusions", value = "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源
+ }
+)
+public class DruidStatFilter extends WebStatFilter {
+}
diff --git a/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/servlet/DruidStatViewServlet.java b/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/servlet/DruidStatViewServlet.java
new file mode 100644
index 0000000..7ee6861
--- /dev/null
+++ b/dubbo-core/src/main/java/com/coderqian/dubbocore/configuration/servlet/DruidStatViewServlet.java
@@ -0,0 +1,26 @@
+package com.coderqian.dubbocore.configuration.servlet;
+
+import com.alibaba.druid.support.http.StatViewServlet;
+
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+
+/**
+ * @author qianliqing
+ * @date 2019-01-18 6:37 PM
+ * mail: qianlq0824@gmail.com
+ *
+ * 配置druid监控统计功能
+ */
+
+@WebServlet(urlPatterns = "/druid/*",
+ initParams = {
+ @WebInitParam(name = "allow", value = "192.168.16.110,127.0.0.1"), // IP白名单 (没有配置或者为空,则允许所有访问)
+ @WebInitParam(name = "deny", value = "192.168.16.111"), // IP黑名单 (存在共同时,deny优先于allow)
+ @WebInitParam(name = "loginUsername", value = "kBEuJPHmTgcVvKlt"),// 用户名
+ @WebInitParam(name = "loginPassword", value = "zPhIJTa0jvsZ7sLj"),// 密码
+ @WebInitParam(name = "resetEnable", value = "false")// 禁用HTML页面上的“Reset All”功能
+ }
+)
+public class DruidStatViewServlet extends StatViewServlet {
+}
diff --git a/dubbo-core/src/main/java/com/coderqian/dubbocore/mapper/UserMapper.java b/dubbo-core/src/main/java/com/coderqian/dubbocore/mapper/UserMapper.java
new file mode 100644
index 0000000..51939aa
--- /dev/null
+++ b/dubbo-core/src/main/java/com/coderqian/dubbocore/mapper/UserMapper.java
@@ -0,0 +1,23 @@
+package com.coderqian.dubbocore.mapper;
+
+import com.coderqian.dubbocore.model.entity.UserEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @author qianliqing
+ * @date 2019/1/18 7:58 PM
+ * email: qianliqing@hyperchain.com
+ */
+
+@Mapper
+public interface UserMapper {
+
+ /**
+ * 查询所有用户
+ *
+ * @return List
+ */
+ List findAll();
+}
diff --git a/dubbo-core/src/main/java/com/coderqian/dubbocore/model/entity/BaseEntity.java b/dubbo-core/src/main/java/com/coderqian/dubbocore/model/entity/BaseEntity.java
new file mode 100644
index 0000000..0b07856
--- /dev/null
+++ b/dubbo-core/src/main/java/com/coderqian/dubbocore/model/entity/BaseEntity.java
@@ -0,0 +1,13 @@
+package com.coderqian.dubbocore.model.entity;
+
+import lombok.Data;
+
+/**
+ * @author qianliqing
+ * @date 2019/1/18 6:59 PM
+ * email: qianlq0824@gmail.com
+ */
+
+@Data
+public abstract class BaseEntity {
+}
diff --git a/dubbo-core/src/main/java/com/coderqian/dubbocore/model/entity/UserEntity.java b/dubbo-core/src/main/java/com/coderqian/dubbocore/model/entity/UserEntity.java
new file mode 100644
index 0000000..5d71637
--- /dev/null
+++ b/dubbo-core/src/main/java/com/coderqian/dubbocore/model/entity/UserEntity.java
@@ -0,0 +1,19 @@
+package com.coderqian.dubbocore.model.entity;
+
+import lombok.Data;
+
+/**
+ * @author qianliqing
+ * @date 2019/1/18 6:59 PM
+ * email: qianlq0824@gmail.com
+ */
+
+@Data
+public class UserEntity extends BaseEntity {
+
+ private String id;
+
+ private String name;
+
+ private String birth;
+}
diff --git a/dubbo-core/src/main/resources/application.properties b/dubbo-core/src/main/resources/application.properties
new file mode 100644
index 0000000..3c19740
--- /dev/null
+++ b/dubbo-core/src/main/resources/application.properties
@@ -0,0 +1,29 @@
+spring.application.name=dubbo-core
+server.port=8020
+
+# 当前dubbo应用id
+dubbo.application.id=dubbo-core
+# 当前dubbo应用名称
+dubbo.application.name=dubbo-core
+# 注册中心
+dubbo.registry.address=zookeeper://127.0.0.1:2181
+dubbo.registry.timeout=60000
+dubbo.registry.group=dubbo
+dubbo.registry.check=false
+
+dubbo.server=true
+# 生产者暴露给消费者协议
+dubbo.protocol.name=dubbo
+# 生产者暴露给消费者端口
+dubbo.protocol.port=20880
+
+logging.config=classpath:log4j2.xml
+
+spring.datasource.url=
+spring.datasource.username=
+spring.datasource.password=
+
+spring.datasource.driver-class-name=com.mysql.jdbc.Driver
+spring.datasource.initialSize=5
+spring.datasource.minIdle=5
+spring.datasource.maxActive=20
\ No newline at end of file
diff --git a/dubbo-core/src/main/resources/mapper/UserMapper.xml b/dubbo-core/src/main/resources/mapper/UserMapper.xml
new file mode 100644
index 0000000..0790f15
--- /dev/null
+++ b/dubbo-core/src/main/resources/mapper/UserMapper.xml
@@ -0,0 +1,20 @@
+
+
+
+
+ id id,
+ name name,
+ birth birth
+
+
+
+ user
+
+
+
+
\ No newline at end of file
diff --git a/dubbo-core/src/test/java/com/coderqian/dubbocore/DubboCoreApplicationTests.java b/dubbo-core/src/test/java/com/coderqian/dubbocore/DubboCoreApplicationTests.java
new file mode 100644
index 0000000..ef83fa6
--- /dev/null
+++ b/dubbo-core/src/test/java/com/coderqian/dubbocore/DubboCoreApplicationTests.java
@@ -0,0 +1,17 @@
+package com.coderqian.dubbocore;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class DubboCoreApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
+
diff --git a/dubbo-provider/pom.xml b/dubbo-provider/pom.xml
index 22625dd..af82bbd 100644
--- a/dubbo-provider/pom.xml
+++ b/dubbo-provider/pom.xml
@@ -9,7 +9,7 @@
com.coderqian
- spring-boot-dubbo-cli
+ dubbo-spring-boot-cli
1.0-SNAPSHOT
@@ -20,77 +20,16 @@
UTF-8
UTF-8
1.8
- Finchley.RELEASE
com.coderqian
- dubbo-api
+ dubbo-service
0.0.1-SNAPSHOT
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-netflix-hystrix
- 2.0.1.RELEASE
-
-
-
- org.apache.zookeeper
- zookeeper
- 3.4.13
-
-
- org.slf4j
- slf4j-log4j12
-
-
- log4j
- log4j
-
-
-
-
-
- com.101tec
- zkclient
- 0.2
-
-
- slf4j-api
- org.slf4j
-
-
- log4j
- log4j
-
-
- slf4j-log4j12
- org.slf4j
-
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-dependencies
- ${spring-cloud.version}
- pom
- import
-
-
-
-
diff --git a/dubbo-provider/src/main/java/com/coderqian/dubboprovider/DubboProviderApplication.java b/dubbo-provider/src/main/java/com/coderqian/dubboprovider/DubboProviderApplication.java
index 4791a45..c29a407 100644
--- a/dubbo-provider/src/main/java/com/coderqian/dubboprovider/DubboProviderApplication.java
+++ b/dubbo-provider/src/main/java/com/coderqian/dubboprovider/DubboProviderApplication.java
@@ -3,10 +3,8 @@
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.hystrix.EnableHystrix;
@EnableDubbo
-@EnableHystrix
@SpringBootApplication
//@ImportResource({"classpath:dubbo/dubbo-provider.xml"})
public class DubboProviderApplication {
diff --git a/dubbo-provider/src/main/java/com/coderqian/dubboprovider/service/impl/TestServiceImpl.java b/dubbo-provider/src/main/java/com/coderqian/dubboprovider/service/impl/TestServiceImpl.java
deleted file mode 100644
index 6606918..0000000
--- a/dubbo-provider/src/main/java/com/coderqian/dubboprovider/service/impl/TestServiceImpl.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.coderqian.dubboprovider.service.impl;
-
-import com.alibaba.dubbo.config.annotation.Service;
-import com.coderqian.dubboapi.service.TestService;
-import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
-import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
-import io.swagger.annotations.ApiParam;
-
-/**
- * @author qianliqing
- * @date 2018/11/29 12:53 PM
- * email: qianlq0824@gmail.com
- */
-
-@Service
-public class TestServiceImpl implements TestService {
-
- @HystrixCommand(commandProperties = {
- @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "3"),
- @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "2000")
- })
- @Override
- public String test(@ApiParam(value = "测试数据", required = true) String text) {
- return text;
- }
-}
diff --git a/dubbo-provider/src/main/resources/application.properties b/dubbo-provider/src/main/resources/application.properties
index c092958..b7de02f 100644
--- a/dubbo-provider/src/main/resources/application.properties
+++ b/dubbo-provider/src/main/resources/application.properties
@@ -17,4 +17,4 @@ dubbo.protocol.name=dubbo
# 生产者暴露给消费者端口
dubbo.protocol.port=20880
-logging.config=classpath:log4j2.xml
+logging.config=classpath:log4j2.xml
\ No newline at end of file
diff --git a/dubbo-provider/src/main/resources/dubbo/dubbo-providers.xml b/dubbo-provider/src/main/resources/dubbo/dubbo-providers.xml
index a75969e..18c61ac 100644
--- a/dubbo-provider/src/main/resources/dubbo/dubbo-providers.xml
+++ b/dubbo-provider/src/main/resources/dubbo/dubbo-providers.xml
@@ -15,6 +15,6 @@ http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
-
+
\ No newline at end of file
diff --git a/dubbo-provider/src/main/resources/log4j2.xml b/dubbo-provider/src/main/resources/log4j2.xml
deleted file mode 100644
index beb1138..0000000
--- a/dubbo-provider/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
- %d{yyyy-MM-dd HH:mm:ss} [Thread: %t] [ %-5p] %c{1}:%L - %m%n
- logs
- dubbo-provider
-
-
-
-
- ${pattern}
-
-
-
-
-
-
- ${pattern}
-
-
-
-
-
-
- ${pattern}
-
-
-
-
-
-
-
-
-
- ${pattern}
-
-
-
-
-
-
-
-
-
- ${pattern}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dubbo-service/pom.xml b/dubbo-service/pom.xml
new file mode 100644
index 0000000..e885138
--- /dev/null
+++ b/dubbo-service/pom.xml
@@ -0,0 +1,81 @@
+
+
+ 4.0.0
+
+ dubbo-service
+ 0.0.1-SNAPSHOT
+ jar
+
+
+ com.coderqian
+ dubbo-spring-boot-cli
+ 1.0-SNAPSHOT
+
+
+ dubbo-service
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ com.coderqian
+ dubbo-api
+ 0.0.1-SNAPSHOT
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.apache.zookeeper
+ zookeeper
+ 3.4.13
+
+
+ org.slf4j
+ slf4j-log4j12
+
+
+ log4j
+ log4j
+
+
+
+
+
+ com.101tec
+ zkclient
+ 0.2
+
+
+ slf4j-api
+ org.slf4j
+
+
+ log4j
+ log4j
+
+
+ slf4j-log4j12
+ org.slf4j
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/dubbo-service/src/main/java/com/coderqian/dubboservice/DubboServiceApplication.java b/dubbo-service/src/main/java/com/coderqian/dubboservice/DubboServiceApplication.java
new file mode 100644
index 0000000..3292f1e
--- /dev/null
+++ b/dubbo-service/src/main/java/com/coderqian/dubboservice/DubboServiceApplication.java
@@ -0,0 +1,14 @@
+package com.coderqian.dubboservice;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DubboServiceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboServiceApplication.class, args);
+ }
+
+}
+
diff --git a/dubbo-service/src/main/java/com/coderqian/dubboservice/service/impl/TestServiceImpl.java b/dubbo-service/src/main/java/com/coderqian/dubboservice/service/impl/TestServiceImpl.java
new file mode 100644
index 0000000..7e89355
--- /dev/null
+++ b/dubbo-service/src/main/java/com/coderqian/dubboservice/service/impl/TestServiceImpl.java
@@ -0,0 +1,37 @@
+package com.coderqian.dubboservice.service.impl;
+
+import com.alibaba.dubbo.config.annotation.Service;
+import com.coderqian.dubboapi.service.TestService;
+import com.coderqian.dubbocore.mapper.UserMapper;
+import com.coderqian.dubbocore.model.entity.UserEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+/**
+ * @author qianliqing
+ * @date 2019-01-19 12:55 AM
+ * mail: qianlq0824@gmail.com
+ */
+
+@Service
+public class TestServiceImpl implements TestService {
+
+ @Autowired
+ private UserMapper userMapper;
+
+
+ // @HystrixCommand(commandProperties = {
+// @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "3"),
+// @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "2000")
+// })
+ @Override
+ public String test(String text) {
+ return text;
+ }
+
+ @Override
+ public List testMybatis(String text) {
+ return userMapper.findAll();
+ }
+}
diff --git a/dubbo-service/src/main/resources/application.properties b/dubbo-service/src/main/resources/application.properties
new file mode 100644
index 0000000..ad7bf09
--- /dev/null
+++ b/dubbo-service/src/main/resources/application.properties
@@ -0,0 +1,20 @@
+spring.application.name=dubbo-service
+server.port=8081
+
+# 当前dubbo应用id
+dubbo.application.id=dubbo-service
+# 当前dubbo应用名称
+dubbo.application.name=dubbo-service
+# 注册中心
+dubbo.registry.address=zookeeper://127.0.0.1:2181
+dubbo.registry.timeout=60000
+dubbo.registry.group=dubbo
+dubbo.registry.check=false
+
+dubbo.server=true
+# 生产者暴露给消费者协议
+dubbo.protocol.name=dubbo
+# 生产者暴露给消费者端口
+dubbo.protocol.port=20880
+
+logging.config=classpath:log4j2.xml
\ No newline at end of file
diff --git a/dubbo-api/src/main/resources/log4j2.xml b/dubbo-service/src/main/resources/log4j2.xml
similarity index 98%
rename from dubbo-api/src/main/resources/log4j2.xml
rename to dubbo-service/src/main/resources/log4j2.xml
index 6c7f016..5d7e10c 100644
--- a/dubbo-api/src/main/resources/log4j2.xml
+++ b/dubbo-service/src/main/resources/log4j2.xml
@@ -6,7 +6,7 @@
%d{yyyy-MM-dd HH:mm:ss} [Thread: %t] [ %-5p] %c{1}:%L - %m%n
logs
- dubbo-api
+ dubbo-service
diff --git a/dubbo-service/src/test/java/com/coderqian/dubboservice/DubboServiceApplicationTests.java b/dubbo-service/src/test/java/com/coderqian/dubboservice/DubboServiceApplicationTests.java
new file mode 100644
index 0000000..07d5726
--- /dev/null
+++ b/dubbo-service/src/test/java/com/coderqian/dubboservice/DubboServiceApplicationTests.java
@@ -0,0 +1,17 @@
+package com.coderqian.dubboservice;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class DubboServiceApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
+
diff --git a/pom.xml b/pom.xml
index d0bbc05..b5732c6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,14 @@
4.0.0
com.coderqian
- spring-boot-dubbo-cli
+ dubbo-spring-boot-cli
1.0-SNAPSHOT
pom
dubbo-api
+ dubbo-core
+ dubbo-service
dubbo-provider
dubbo-consumer