diff --git a/xjs-business/xjs-project-mall/mall-product/src/main/resources/mapper/product/ProductAttrValueDao.xml b/xjs-business/xjs-project-mall/mall-product/src/main/resources/mapper/product/ProductAttrValueDao.xml index 8a483779..d3a782ec 100644 --- a/xjs-business/xjs-project-mall/mall-product/src/main/resources/mapper/product/ProductAttrValueDao.xml +++ b/xjs-business/xjs-project-mall/mall-product/src/main/resources/mapper/product/ProductAttrValueDao.xml @@ -13,6 +13,39 @@ + + + + + + + + + + + - \ No newline at end of file + diff --git a/xjs-study/dubbo-project/pom.xml b/xjs-study/dubbo-project/pom.xml new file mode 100644 index 00000000..d7470d5e --- /dev/null +++ b/xjs-study/dubbo-project/pom.xml @@ -0,0 +1,109 @@ + + + + xjs-study + com.xjs + 1.0 + + 4.0.0 + pom + dubbo项目 + + service-api + service-provider + service-consumer + + + dubbo-project + + + 11 + 11 + 2.7.5 + + + + + + org.apache.dubbo + dubbo + ${dubbo.version} + + + org.apache.dubbo + dubbo-common + ${dubbo.version} + + + org.apache.dubbo + dubbo-registry-zookeeper + ${dubbo.version} + + + org.apache.dubbo + dubbo-registry-nacos + ${dubbo.version} + + + org.apache.dubbo + dubbo-rpc-dubbo + ${dubbo.version} + + + org.apache.dubbo + dubbo-remoting-netty4 + ${dubbo.version} + + + org.apache.dubbo + dubbo-serialization-hessian2 + ${dubbo.version} + + + + + + + + log4j + log4j + 1.2.16 + + + org.slf4j + slf4j-api + 1.7.5 + + + org.slf4j + slf4j-log4j12 + 1.7.5 + + + + + com.alibaba + fastjson + 1.2.62 + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + + + + + + diff --git a/xjs-study/dubbo-project/service-api/pom.xml b/xjs-study/dubbo-project/service-api/pom.xml new file mode 100644 index 00000000..590b8425 --- /dev/null +++ b/xjs-study/dubbo-project/service-api/pom.xml @@ -0,0 +1,20 @@ + + + + dubbo-project + com.xjs + 1.0 + + 4.0.0 + dubbo服务API + + service-api + + + 11 + 11 + + + diff --git a/xjs-study/dubbo-project/service-api/src/main/java/com/xjs/service/HelloService.java b/xjs-study/dubbo-project/service-api/src/main/java/com/xjs/service/HelloService.java new file mode 100644 index 00000000..6972a56f --- /dev/null +++ b/xjs-study/dubbo-project/service-api/src/main/java/com/xjs/service/HelloService.java @@ -0,0 +1,9 @@ +package com.xjs.service; + +/** + * @author xiejs + * @since 2022-05-23 + */ +public interface HelloService { + String sayHello(String name); +} diff --git a/xjs-study/dubbo-project/service-consumer/pom.xml b/xjs-study/dubbo-project/service-consumer/pom.xml new file mode 100644 index 00000000..7cddca10 --- /dev/null +++ b/xjs-study/dubbo-project/service-consumer/pom.xml @@ -0,0 +1,54 @@ + + + + dubbo-project + com.xjs + 1.0 + + 4.0.0 + dubbo服务消费者 + + service-consumer + + + 11 + 11 + + + + + com.xjs + service-api + 1.0 + + + + org.apache.dubbo + dubbo + + + org.apache.dubbo + dubbo-common + + + + org.apache.dubbo + dubbo-registry-nacos + + + org.apache.dubbo + dubbo-rpc-dubbo + + + org.apache.dubbo + dubbo-remoting-netty4 + + + org.apache.dubbo + dubbo-serialization-hessian2 + + + + diff --git a/xjs-study/dubbo-project/service-consumer/src/main/java/com/xjs/AnnotationConsumerApplication.java b/xjs-study/dubbo-project/service-consumer/src/main/java/com/xjs/AnnotationConsumerApplication.java new file mode 100644 index 00000000..164afd30 --- /dev/null +++ b/xjs-study/dubbo-project/service-consumer/src/main/java/com/xjs/AnnotationConsumerApplication.java @@ -0,0 +1,43 @@ +package com.xjs; + +import com.xjs.bean.ConsumerComponent; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import java.io.IOException; + +/** + * @author xiejs + * @since 2022-05-23 + */ +public class AnnotationConsumerApplication { + + public static void main(String[] args) throws IOException { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class); + context.start(); + + //获取消费者组件 + ConsumerComponent service = context.getBean(ConsumerComponent.class); + + while (true) { + System.in.read(); + String hello = service.sayHello("傻逼"); + + System.out.println(hello); + } + + } + + @Configuration + @PropertySource("classpath:/dubbo-consumer.properties") + @ComponentScan(basePackages = "com.xjs.bean") + @EnableDubbo + static class ConsumerConfiguration{ + + } + + +} diff --git a/xjs-study/dubbo-project/service-consumer/src/main/java/com/xjs/bean/ConsumerComponent.java b/xjs-study/dubbo-project/service-consumer/src/main/java/com/xjs/bean/ConsumerComponent.java new file mode 100644 index 00000000..18187355 --- /dev/null +++ b/xjs-study/dubbo-project/service-consumer/src/main/java/com/xjs/bean/ConsumerComponent.java @@ -0,0 +1,21 @@ +package com.xjs.bean; + +import com.xjs.service.HelloService; +import org.apache.dubbo.config.annotation.Reference; +import org.springframework.stereotype.Component; + +/** + * @author xiejs + * @since 2022-05-23 + */ +@Component +public class ConsumerComponent { + + @Reference + private HelloService helloService; + + public String sayHello(String name) { + return helloService.sayHello(name); + } + +} diff --git a/xjs-study/dubbo-project/service-consumer/src/main/resources/dubbo-consumer.properties b/xjs-study/dubbo-project/service-consumer/src/main/resources/dubbo-consumer.properties new file mode 100644 index 00000000..60f43aee --- /dev/null +++ b/xjs-study/dubbo-project/service-consumer/src/main/resources/dubbo-consumer.properties @@ -0,0 +1,8 @@ +dubbo.application.name=service-consumer + + + + +dubbo.registry.address=nacos://127.0.0.1:8848 + + diff --git a/xjs-study/dubbo-project/service-consumer/src/main/resources/log4j.properties b/xjs-study/dubbo-project/service-consumer/src/main/resources/log4j.properties new file mode 100644 index 00000000..0dab4e31 --- /dev/null +++ b/xjs-study/dubbo-project/service-consumer/src/main/resources/log4j.properties @@ -0,0 +1,5 @@ +log4j.rootCategory=INFO,CONSOLE + +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss.SSS} [%t] %-5p %c.%M\(%F:%L\) - %m%n diff --git a/xjs-study/dubbo-project/service-provider/pom.xml b/xjs-study/dubbo-project/service-provider/pom.xml new file mode 100644 index 00000000..71be7a2b --- /dev/null +++ b/xjs-study/dubbo-project/service-provider/pom.xml @@ -0,0 +1,54 @@ + + + + dubbo-project + com.xjs + 1.0 + + 4.0.0 + dubbo服务生产者 + + service-provider + + + 11 + 11 + + + + + com.xjs + service-api + 1.0 + + + + org.apache.dubbo + dubbo + + + org.apache.dubbo + dubbo-common + + + + org.apache.dubbo + dubbo-registry-nacos + + + org.apache.dubbo + dubbo-rpc-dubbo + + + org.apache.dubbo + dubbo-remoting-netty4 + + + org.apache.dubbo + dubbo-serialization-hessian2 + + + + diff --git a/xjs-study/dubbo-project/service-provider/src/main/java/com/xjs/DubboApplication.java b/xjs-study/dubbo-project/service-provider/src/main/java/com/xjs/DubboApplication.java new file mode 100644 index 00000000..49636d47 --- /dev/null +++ b/xjs-study/dubbo-project/service-provider/src/main/java/com/xjs/DubboApplication.java @@ -0,0 +1,35 @@ +package com.xjs; + +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import java.io.IOException; + +/** + * @author xiejs + * @since 2022-05-23 + */ +public class DubboApplication { + + public static void main(String[] args) throws IOException { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class); + context.start(); + System.in.read(); + } + + @Configuration + @EnableDubbo(scanBasePackages = "com.xjs.service") + @PropertySource("classpath:/dubbo-provider.properties") + static class ProviderConfiguration{ + @Bean + public RegistryConfig registryConfig() { + RegistryConfig registryConfig = new RegistryConfig(); + registryConfig.setAddress("nacos://127.0.0.1:8848"); + return registryConfig; + } + } +} diff --git a/xjs-study/dubbo-project/service-provider/src/main/java/com/xjs/service/HelloServiceImpl.java b/xjs-study/dubbo-project/service-provider/src/main/java/com/xjs/service/HelloServiceImpl.java new file mode 100644 index 00000000..8fb14217 --- /dev/null +++ b/xjs-study/dubbo-project/service-provider/src/main/java/com/xjs/service/HelloServiceImpl.java @@ -0,0 +1,15 @@ +package com.xjs.service; + +import org.apache.dubbo.config.annotation.Service; + +/** + * @author xiejs + * @since 2022-05-23 + */ +@Service +public class HelloServiceImpl implements HelloService{ + @Override + public String sayHello(String name) { + return "Hello:"+name; + } +} diff --git a/xjs-study/dubbo-project/service-provider/src/main/resources/dubbo-provider.properties b/xjs-study/dubbo-project/service-provider/src/main/resources/dubbo-provider.properties new file mode 100644 index 00000000..9441cb13 --- /dev/null +++ b/xjs-study/dubbo-project/service-provider/src/main/resources/dubbo-provider.properties @@ -0,0 +1,8 @@ +dubbo.application.name=service-provider + +dubbo.protocol.name=dubbo + +dubbo.protocol.port=7711 + + + diff --git a/xjs-study/dubbo-project/service-provider/src/main/resources/log4j.properties b/xjs-study/dubbo-project/service-provider/src/main/resources/log4j.properties new file mode 100644 index 00000000..0dab4e31 --- /dev/null +++ b/xjs-study/dubbo-project/service-provider/src/main/resources/log4j.properties @@ -0,0 +1,5 @@ +log4j.rootCategory=INFO,CONSOLE + +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss.SSS} [%t] %-5p %c.%M\(%F:%L\) - %m%n diff --git a/xjs-study/pom.xml b/xjs-study/pom.xml index 8e72c161..d8ee18c0 100644 --- a/xjs-study/pom.xml +++ b/xjs-study/pom.xml @@ -13,6 +13,7 @@ xjs-study-base netty-project + dubbo-project xjs-study @@ -24,4 +25,4 @@ 11 - \ No newline at end of file +