From ffa69c65aef7051aae75b677df378ae6b3c8d771 Mon Sep 17 00:00:00 2001 From: qianlq <1242202279@qq.com> Date: Sun, 20 Jan 2019 11:43:53 +0800 Subject: [PATCH] =?UTF-8?q?:collision:=20feat(DAO=E5=B1=82):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=BA=93=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dubbo-api/pom.xml | 15 ++-- .../src/main/resources/application.properties | 16 +++- .../DubboConsumerApplication.java | 2 + .../controller/TestController.java | 2 +- .../src/main/resources/application.properties | 18 +++-- .../src/main/resources/mapper/UserMapper.xml | 4 +- dubbo-provider/pom.xml | 43 +++++++++- .../service/impl/TestServiceImpl.java | 9 +-- .../src/main/resources/application.properties | 4 +- ...dubbo-providers.xml => dubbo-provider.xml} | 2 +- dubbo-service/pom.xml | 81 ------------------- .../dubboservice/DubboServiceApplication.java | 14 ---- .../src/main/resources/application.properties | 20 ----- dubbo-service/src/main/resources/log4j2.xml | 73 ----------------- .../DubboServiceApplicationTests.java | 17 ---- pom.xml | 1 - 16 files changed, 90 insertions(+), 231 deletions(-) rename {dubbo-service/src/main/java/com/coderqian/dubboservice => dubbo-provider/src/main/java/com/coderqian/dubboprovider}/service/impl/TestServiceImpl.java (79%) rename dubbo-provider/src/main/resources/dubbo/{dubbo-providers.xml => dubbo-provider.xml} (91%) delete mode 100644 dubbo-service/pom.xml delete mode 100644 dubbo-service/src/main/java/com/coderqian/dubboservice/DubboServiceApplication.java delete mode 100644 dubbo-service/src/main/resources/application.properties delete mode 100644 dubbo-service/src/main/resources/log4j2.xml delete mode 100644 dubbo-service/src/test/java/com/coderqian/dubboservice/DubboServiceApplicationTests.java diff --git a/dubbo-api/pom.xml b/dubbo-api/pom.xml index 8f73f83..b046a26 100644 --- a/dubbo-api/pom.xml +++ b/dubbo-api/pom.xml @@ -27,11 +27,16 @@ com.coderqian dubbo-core 0.0.1-SNAPSHOT - - - - org.springframework.boot - spring-boot-starter-web + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + + + com.alibaba + druid-spring-boot-starter + + diff --git a/dubbo-api/src/main/resources/application.properties b/dubbo-api/src/main/resources/application.properties index 8e3d0f3..06410c3 100644 --- a/dubbo-api/src/main/resources/application.properties +++ b/dubbo-api/src/main/resources/application.properties @@ -6,4 +6,18 @@ dubbo.application.id=dubbo-api # 当前dubbo应用名称 dubbo.application.name=dubbo-api # 注册中心 -dubbo.registry.address=zookeeper://127.0.0.1:2181 \ No newline at end of file +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 + +#spring.datasource.driver-class-name=com.mysql.jdbc.Driver +#spring.datasource.url=jdbc:mysql://127.0.0。1:3306/test?useUnicode=true&characterEncoding=utf8&verifyServerCertificate=false&useSSL=false&useOldAliasMetadataBehavior=true +#spring.datasource.username= +#spring.datasource.password= \ No newline at end of file diff --git a/dubbo-consumer/src/main/java/com/coderqian/dubboconsumer/DubboConsumerApplication.java b/dubbo-consumer/src/main/java/com/coderqian/dubboconsumer/DubboConsumerApplication.java index fa14e77..007c6ae 100644 --- a/dubbo-consumer/src/main/java/com/coderqian/dubboconsumer/DubboConsumerApplication.java +++ b/dubbo-consumer/src/main/java/com/coderqian/dubboconsumer/DubboConsumerApplication.java @@ -1,8 +1,10 @@ package com.coderqian.dubboconsumer; +import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +@EnableDubbo @SpringBootApplication //@ImportResource({"classpath:dubbo/dubbo-customer.xml"}) public class DubboConsumerApplication { diff --git a/dubbo-consumer/src/main/java/com/coderqian/dubboconsumer/controller/TestController.java b/dubbo-consumer/src/main/java/com/coderqian/dubboconsumer/controller/TestController.java index aba1630..cca583d 100644 --- a/dubbo-consumer/src/main/java/com/coderqian/dubboconsumer/controller/TestController.java +++ b/dubbo-consumer/src/main/java/com/coderqian/dubboconsumer/controller/TestController.java @@ -20,7 +20,7 @@ @RequestMapping("/test") public class TestController { - @Reference + @Reference(version = "1.0.0", timeout = 5000, interfaceClass = TestService.class, check = false) private TestService testService; @HystrixCommand(fallbackMethod = "testError") diff --git a/dubbo-core/src/main/resources/application.properties b/dubbo-core/src/main/resources/application.properties index 3c19740..07da011 100644 --- a/dubbo-core/src/main/resources/application.properties +++ b/dubbo-core/src/main/resources/application.properties @@ -1,5 +1,5 @@ spring.application.name=dubbo-core -server.port=8020 +server.port=3000 # 当前dubbo应用id dubbo.application.id=dubbo-core @@ -17,13 +17,19 @@ dubbo.protocol.name=dubbo # 生产者暴露给消费者端口 dubbo.protocol.port=20880 -logging.config=classpath:log4j2.xml +# Mybatis配置 +mybatis.type-aliases-package=com.coderqian.dubbocore.model.entity +mybatis.type-handlers-package=com.coderqian.dubbocore.mapper +mybatis.mapper-locations=classpath:mapper/*.xml -spring.datasource.url= -spring.datasource.username= -spring.datasource.password= +# 配置数据源 +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 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 +spring.datasource.maxActive=20 + +spring.datasource.url=jdbc:mysql://127.0.0。1:3306/test?useUnicode=true&characterEncoding=utf8&verifyServerCertificate=false&useSSL=false&useOldAliasMetadataBehavior=true +spring.datasource.username=root +spring.datasource.password=qlq1995/ \ 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 index 0790f15..a695aa9 100644 --- a/dubbo-core/src/main/resources/mapper/UserMapper.xml +++ b/dubbo-core/src/main/resources/mapper/UserMapper.xml @@ -1,6 +1,6 @@ - + id id, name name, @@ -11,7 +11,7 @@ user - select from diff --git a/dubbo-provider/pom.xml b/dubbo-provider/pom.xml index af82bbd..4772c22 100644 --- a/dubbo-provider/pom.xml +++ b/dubbo-provider/pom.xml @@ -25,9 +25,50 @@ com.coderqian - dubbo-service + 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 + + + diff --git a/dubbo-service/src/main/java/com/coderqian/dubboservice/service/impl/TestServiceImpl.java b/dubbo-provider/src/main/java/com/coderqian/dubboprovider/service/impl/TestServiceImpl.java similarity index 79% rename from dubbo-service/src/main/java/com/coderqian/dubboservice/service/impl/TestServiceImpl.java rename to dubbo-provider/src/main/java/com/coderqian/dubboprovider/service/impl/TestServiceImpl.java index 7e89355..a1de769 100644 --- a/dubbo-service/src/main/java/com/coderqian/dubboservice/service/impl/TestServiceImpl.java +++ b/dubbo-provider/src/main/java/com/coderqian/dubboprovider/service/impl/TestServiceImpl.java @@ -1,8 +1,7 @@ -package com.coderqian.dubboservice.service.impl; +package com.coderqian.dubboprovider.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; @@ -14,11 +13,11 @@ * mail: qianlq0824@gmail.com */ -@Service +@Service(version = "1.0.0", timeout = 5000, interfaceClass = TestService.class) public class TestServiceImpl implements TestService { @Autowired - private UserMapper userMapper; + private TestService testService; // @HystrixCommand(commandProperties = { @@ -32,6 +31,6 @@ public String test(String text) { @Override public List testMybatis(String text) { - return userMapper.findAll(); + return testService.testMybatis("测试"); } } diff --git a/dubbo-provider/src/main/resources/application.properties b/dubbo-provider/src/main/resources/application.properties index b7de02f..fa17fa3 100644 --- a/dubbo-provider/src/main/resources/application.properties +++ b/dubbo-provider/src/main/resources/application.properties @@ -15,6 +15,4 @@ dubbo.server=true # 生产者暴露给消费者协议 dubbo.protocol.name=dubbo # 生产者暴露给消费者端口 -dubbo.protocol.port=20880 - -logging.config=classpath:log4j2.xml \ No newline at end of file +dubbo.protocol.port=20880 \ 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-provider.xml similarity index 91% rename from dubbo-provider/src/main/resources/dubbo/dubbo-providers.xml rename to dubbo-provider/src/main/resources/dubbo/dubbo-provider.xml index 18c61ac..a75969e 100644 --- a/dubbo-provider/src/main/resources/dubbo/dubbo-providers.xml +++ b/dubbo-provider/src/main/resources/dubbo/dubbo-provider.xml @@ -15,6 +15,6 @@ http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> - + \ No newline at end of file diff --git a/dubbo-service/pom.xml b/dubbo-service/pom.xml deleted file mode 100644 index e885138..0000000 --- a/dubbo-service/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - 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 deleted file mode 100644 index 3292f1e..0000000 --- a/dubbo-service/src/main/java/com/coderqian/dubboservice/DubboServiceApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -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/resources/application.properties b/dubbo-service/src/main/resources/application.properties deleted file mode 100644 index ad7bf09..0000000 --- a/dubbo-service/src/main/resources/application.properties +++ /dev/null @@ -1,20 +0,0 @@ -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-service/src/main/resources/log4j2.xml b/dubbo-service/src/main/resources/log4j2.xml deleted file mode 100644 index 5d7e10c..0000000 --- a/dubbo-service/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-service - - - - - ${pattern} - - - - - - - ${pattern} - - - - - - - ${pattern} - - - - - - - - - - ${pattern} - - - - - - - - - - ${pattern} - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/dubbo-service/src/test/java/com/coderqian/dubboservice/DubboServiceApplicationTests.java b/dubbo-service/src/test/java/com/coderqian/dubboservice/DubboServiceApplicationTests.java deleted file mode 100644 index 07d5726..0000000 --- a/dubbo-service/src/test/java/com/coderqian/dubboservice/DubboServiceApplicationTests.java +++ /dev/null @@ -1,17 +0,0 @@ -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 b5732c6..4a27282 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,6 @@ dubbo-api dubbo-core - dubbo-service dubbo-provider dubbo-consumer