Commit efe4ba98 by ethanlamzs

refactor 业务层

1 parent 94314d9d
Showing 44 changed files with 129 additions and 297 deletions
package com.zhzf.fpj.xcx.api.demo; package com.zhzf.fpj.xcx.api.demo;
public interface DemoService { public interface DemoProvider {
String sayHello(String name); String sayHello(String name);
......
package com.zhzf.fpj.xcx.api.demo; package com.zhzf.fpj.xcx.api.demo;
public interface DemoServiceOther { public interface DemoProviderOther {
String sayHelloOther(String name); String sayHelloOther(String name);
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-buiness-demo-sec</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>buiness-dao-demo-sec</artifactId>
<name>buiness-dao-demo-sec</name>
<description>buiness-dao-demo-sec</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>io.shardingjdbc</groupId>
<artifactId>sharding-jdbc-orchestration-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-buiness-demo-sec</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>buiness-service-demo-sec</artifactId>
<name>buiness-service-demo-sec</name>
<description>buiness-service-demo-sec</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-dao-demo-sec</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.zhzf.fpj.xcx.demo.service;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DemoServiceIn {
@Autowired(required = false)
private DemoService demoService;
public void testExecute(String appfrom){
System.out.println("#######demo-sec-testExecute ["+ appfrom+"] #########");
demoService.demo(appfrom);
}
}
package com.zhzf.fpj.xcx.demo.service;
import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
//@ComponentScan("com.zhzf.fpj.xcx.demo")
public class SpringBootDataServiceMain {
// CHECKSTYLE:OFF
public static void main(final String[] args) {
// CHECKSTYLE:ON
Object[] starts = new Object[2];
starts[0] = SpringBootDataMybatisMain.class;
starts[1] = SpringBootDataServiceMain.class;
ApplicationContext applicationContext = SpringApplication.run(starts, args);
//ApplicationContext applicationContext = SpringApplication.run(com.zhzf.fpj.xcx.demo.service.SpringBootDataServiceMain.class, args);
//applicationContext.getBean(DemoServiceIn.class).testExecute();
}
}
...@@ -8,17 +8,31 @@ ...@@ -8,17 +8,31 @@
</parent> </parent>
<artifactId>core-buiness-demo-sec</artifactId> <artifactId>core-buiness-demo-sec</artifactId>
<name>core-buiness-demo-sec</name> <name>core-buiness-demo-sec</name>
<description>core-buiness-demo-sec 业务代码的输出</description> <description>core-buiness-demo-sec</description>
<packaging>pom</packaging> <packaging>jar</packaging>
<modules>
<module>buiness-service-demo-sec</module>
<module>buiness-dao-demo-sec</module>
</modules>
<dependencies> <dependencies>
<dependency>
<groupId>io.shardingjdbc</groupId>
<artifactId>sharding-jdbc-orchestration-spring-boot-starter</artifactId>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -49,7 +49,6 @@ public class SpringBootDataMybatisMain { ...@@ -49,7 +49,6 @@ public class SpringBootDataMybatisMain {
//app.addListeners(new ApplicationListener2()); //app.addListeners(new ApplicationListener2());
ApplicationContext applicationContext = app.run(args); ApplicationContext applicationContext = app.run(args);
//applicationContext.getBean(DemoService.class).demo("local_dao-demo-sec"); //applicationContext.getBean(DemoService.class).demo("local_dao-demo-sec");
//OrchestrationDataSourceCloseableUtil.closeQuietly(applicationContext.getBean(OrchestrationShardingDataSource.class)); //OrchestrationDataSourceCloseableUtil.closeQuietly(applicationContext.getBean(OrchestrationShardingDataSource.class));
......
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package com.zhzf.fpj.xcx.demo.mybatis.service;
public interface DemoService {
public void demo(String fromapp) ;
}
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
* </p> * </p>
*/ */
package com.zhzf.fpj.xcx.demo.mybatis.service; package com.zhzf.fpj.xcx.demo.mybatis.service.impl;
import com.zhzf.fpj.xcx.demo.mybatis.entity.Order; import com.zhzf.fpj.xcx.demo.mybatis.entity.Order;
import com.zhzf.fpj.xcx.demo.mybatis.entity.OrderItem; import com.zhzf.fpj.xcx.demo.mybatis.entity.OrderItem;
import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderItemRepository; import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderItemRepository;
import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderRepository; import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderRepository;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import com.zhzf.fpj.xcx.utils.DateUtil; import com.zhzf.fpj.xcx.utils.DateUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -29,7 +30,7 @@ import java.util.ArrayList; ...@@ -29,7 +30,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@Service @Service
public class DemoService { public class DemoServiceImpl implements DemoService {
@Resource @Resource
private OrderRepository orderRepository; private OrderRepository orderRepository;
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-buiness-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>buiness-dao-demo</artifactId>
<name>buiness-dao-demo</name>
<description>buiness-dao-demo</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>common-fk-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>core-buiness-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>buiness-service-demo</artifactId>
<name>buiness-service-demo</name>
<description>buiness-service-demo</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-dao-demo</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.zhzf.fpj.xcx.demo.service;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DemoServiceIn {
@Autowired(required = false)
private DemoService demoService;
public void testExecute(String appfrom){
System.out.println("#######demo-testExecute ["+ appfrom+"] #########");
demoService.demo(appfrom);
}
}
package com.zhzf.fpj.xcx.demo.service;
import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
//@ComponentScan("com.zhzf.fpj.xcx.demo")
public class SpringBootDataServiceMain {
// CHECKSTYLE:OFF
public static void main(final String[] args) {
// CHECKSTYLE:ON
Object[] starts = new Object[2];
starts[0] = SpringBootDataMybatisMain.class;
starts[1] = SpringBootDataServiceMain.class;
ApplicationContext applicationContext = SpringApplication.run(starts, args);
//ApplicationContext applicationContext = SpringApplication.run(com.zhzf.fpj.xcx.demo.service.SpringBootDataServiceMain.class, args);
//applicationContext.getBean(DemoServiceIn.class).testExecute();
}
}
...@@ -7,14 +7,9 @@ ...@@ -7,14 +7,9 @@
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>core-buiness-demo</artifactId> <artifactId>core-buiness-demo</artifactId>
<name>core-buiness</name> <name>core-buiness-demo</name>
<description>core-buiness-demo 业务代码的输出</description> <description>core-buiness-demo</description>
<packaging>pom</packaging> <packaging>jar</packaging>
<modules>
<module>buiness-service-demo</module>
<module>buiness-dao-demo</module>
</modules>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -24,4 +19,21 @@ ...@@ -24,4 +19,21 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -37,17 +37,13 @@ public class SpringBootDataMybatisMain { ...@@ -37,17 +37,13 @@ public class SpringBootDataMybatisMain {
public static void main(final String[] args) { public static void main(final String[] args) {
// CHECKSTYLE:ON // CHECKSTYLE:ON
// ApplicationContext applicationContext = SpringApplication.run(SpringBootDataMybatisMain.class, args);
// applicationContext.getBean(DemoService.class).demo();
Object[] starts = new Object[1]; Object[] starts = new Object[1];
starts[0] = SpringBootDataMybatisMain.class; starts[0] = SpringBootDataMybatisMain.class;
SpringApplication app = new SpringApplication(starts); SpringApplication app = new SpringApplication(starts);
app.addListeners(new ApplicationEnvironmentPreparedEventListener()); app.addListeners(new ApplicationEnvironmentPreparedEventListener());
app.addListeners(new ApplicationListener2()); app.addListeners(new ApplicationListener2());
ApplicationContext applicationContext = app.run(args); ApplicationContext applicationContext = app.run(args);
//applicationContext.getBean(DemoService.class).demo("local_demo_dao"); //applicationContext.getBean(DemoService.class).demo("local_demo_dao");
......
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package com.zhzf.fpj.xcx.demo.mybatis.service;
import org.springframework.stereotype.Service;
@Service
public interface DemoService {
public void demo(String fromapp);
}
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
* </p> * </p>
*/ */
package com.zhzf.fpj.xcx.demo.mybatis.service; package com.zhzf.fpj.xcx.demo.mybatis.service.impl;
import com.zhzf.fpj.xcx.demo.mybatis.entity.Order; import com.zhzf.fpj.xcx.demo.mybatis.entity.Order;
import com.zhzf.fpj.xcx.demo.mybatis.entity.OrderItem; import com.zhzf.fpj.xcx.demo.mybatis.entity.OrderItem;
import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderItemRepository; import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderItemRepository;
import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderRepository; import com.zhzf.fpj.xcx.demo.mybatis.repository.OrderRepository;
import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import com.zhzf.fpj.xcx.utils.DateUtil; import com.zhzf.fpj.xcx.utils.DateUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -29,14 +30,14 @@ import java.util.ArrayList; ...@@ -29,14 +30,14 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
@Service @Service
public class DemoService { public class DemoServiceImpl implements DemoService {
@Resource @Resource
private OrderRepository orderRepository; private OrderRepository orderRepository;
@Resource @Resource
private OrderItemRepository orderItemRepository; private OrderItemRepository orderItemRepository;
public void demo(String fromapp) { public void demo(String fromapp) {
orderRepository.createIfNotExistsTable(); orderRepository.createIfNotExistsTable();
orderItemRepository.createIfNotExistsTable(); orderItemRepository.createIfNotExistsTable();
...@@ -52,7 +53,7 @@ public class DemoService { ...@@ -52,7 +53,7 @@ public class DemoService {
orderRepository.insert(order); orderRepository.insert(order);
long orderId = order.getOrderId(); long orderId = order.getOrderId();
orderIds.add(orderId); orderIds.add(orderId);
OrderItem item = new OrderItem(); OrderItem item = new OrderItem();
item.setOrderId(orderId); item.setOrderId(orderId);
item.setUserId(i); item.setUserId(i);
......
...@@ -22,15 +22,10 @@ ...@@ -22,15 +22,10 @@
<dependency> <dependency>
<groupId>com.zhzf.fpj.xcx</groupId> <groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-service-demo-sec</artifactId> <artifactId>core-buiness-demo</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-dao-demo-sec</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> </dependencies>
......
package com.zhzf.fpj.xcx.bootstart; package com.zhzf.fpj.xcx.bootstart;
import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain; import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain;
import com.zhzf.fpj.xcx.demo.service.SpringBootDataServiceMain;
import com.zhzf.fpj.xcx.envir.ApplicationEnvironmentPreparedEventListener; import com.zhzf.fpj.xcx.envir.ApplicationEnvironmentPreparedEventListener;
import com.zhzf.fpj.xcx.envir.ApplicationListener2; import com.zhzf.fpj.xcx.envir.ApplicationListener2;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
...@@ -16,10 +15,9 @@ public class ServiceBootStartApplication { ...@@ -16,10 +15,9 @@ public class ServiceBootStartApplication {
public static void main(String[] args) { public static void main(String[] args) {
Object[] starts = new Object[3]; Object[] starts = new Object[2];
starts[0] = SpringBootDataMybatisMain.class; starts[0] = SpringBootDataMybatisMain.class;
starts[1] = SpringBootDataServiceMain.class; starts[1] = ServiceBootStartApplication.class;
starts[2] = ServiceBootStartApplication.class;
SpringApplication app = new SpringApplication(starts); SpringApplication app = new SpringApplication(starts);
app.addListeners(new ApplicationEnvironmentPreparedEventListener()); app.addListeners(new ApplicationEnvironmentPreparedEventListener());
......
package com.zhzf.fpj.xcx.service; package com.zhzf.fpj.xcx.service;
import com.alibaba.dubbo.config.annotation.Service; import com.alibaba.dubbo.config.annotation.Service;
import com.zhzf.fpj.xcx.api.demo.DemoService; import com.zhzf.fpj.xcx.api.demo.DemoProvider;
import com.zhzf.fpj.xcx.demo.service.DemoServiceIn; import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@Service( @Service(
...@@ -11,13 +11,13 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,13 +11,13 @@ import org.springframework.beans.factory.annotation.Autowired;
protocol = "${dubbo.protocol.id}", protocol = "${dubbo.protocol.id}",
registry = "${dubbo.registry.id}" registry = "${dubbo.registry.id}"
) )
public class TestDemoService implements DemoService { public class TestDemoProvider implements DemoProvider {
@Autowired(required = false) @Autowired(required = false)
private DemoServiceIn demoServiceIn; private DemoService demoService;
public String sayHello(String name) { public String sayHello(String name) {
demoServiceIn.testExecute("core-service-demo"); demoService.demo("core-service-demo");
return "Hello, " + name + " (from Spring Boot)"; return "Hello, " + name + " (from Spring Boot)";
} }
......
...@@ -22,15 +22,10 @@ ...@@ -22,15 +22,10 @@
<dependency> <dependency>
<groupId>com.zhzf.fpj.xcx</groupId> <groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-service-demo</artifactId> <artifactId>core-buiness-demo-sec</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.zhzf.fpj.xcx</groupId>
<artifactId>buiness-dao-demo</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> </dependencies>
......
package com.zhzf.fpj.xcx.bootstart; package com.zhzf.fpj.xcx.bootstart;
import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain; import com.zhzf.fpj.xcx.demo.mybatis.SpringBootDataMybatisMain;
import com.zhzf.fpj.xcx.demo.service.SpringBootDataServiceMain;
import com.zhzf.fpj.xcx.envir.ApplicationEnvironmentPreparedEventListener; import com.zhzf.fpj.xcx.envir.ApplicationEnvironmentPreparedEventListener;
import com.zhzf.fpj.xcx.envir.ApplicationListener2; import com.zhzf.fpj.xcx.envir.ApplicationListener2;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
...@@ -16,10 +15,9 @@ public class ServiceBootStartApplication { ...@@ -16,10 +15,9 @@ public class ServiceBootStartApplication {
public static void main(String[] args) { public static void main(String[] args) {
Object[] starts = new Object[3]; Object[] starts = new Object[2];
starts[0] = SpringBootDataMybatisMain.class; starts[0] = SpringBootDataMybatisMain.class;
starts[1] = SpringBootDataServiceMain.class; starts[1] = ServiceBootStartApplication.class;
starts[2] = ServiceBootStartApplication.class;
SpringApplication app = new SpringApplication(starts); SpringApplication app = new SpringApplication(starts);
app.addListeners(new ApplicationEnvironmentPreparedEventListener()); app.addListeners(new ApplicationEnvironmentPreparedEventListener());
......
package com.zhzf.fpj.xcx.service; package com.zhzf.fpj.xcx.service;
import com.alibaba.dubbo.config.annotation.Service; import com.alibaba.dubbo.config.annotation.Service;
import com.zhzf.fpj.xcx.api.demo.DemoService; import com.zhzf.fpj.xcx.api.demo.DemoProvider;
import com.zhzf.fpj.xcx.api.demo.DemoServiceOther; import com.zhzf.fpj.xcx.api.demo.DemoProviderOther;
import com.zhzf.fpj.xcx.demo.service.DemoServiceIn; import com.zhzf.fpj.xcx.demo.mybatis.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@Service( @Service(
...@@ -12,13 +12,13 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -12,13 +12,13 @@ import org.springframework.beans.factory.annotation.Autowired;
protocol = "${dubbo.protocol.id}", protocol = "${dubbo.protocol.id}",
registry = "${dubbo.registry.id}" registry = "${dubbo.registry.id}"
) )
public class TestDemoService implements DemoServiceOther { public class TestDemoProvider implements DemoProviderOther {
@Autowired(required = false) @Autowired(required = false)
private DemoServiceIn demoServiceIn; private DemoService demoService;
public String sayHelloOther(String name) { public String sayHelloOther(String name) {
demoServiceIn.testExecute("notice"); demoService.demo("notice");
return "Hello, " + name + " (from Spring Boot)"; return "Hello, " + name + " (from Spring Boot)";
} }
......
...@@ -3,8 +3,8 @@ package com.zhzf.fpj.xcx.web.controller; ...@@ -3,8 +3,8 @@ package com.zhzf.fpj.xcx.web.controller;
import com.alibaba.dubbo.config.annotation.Reference; import com.alibaba.dubbo.config.annotation.Reference;
import com.zhzf.fpj.xcx.api.demo.DemoService; import com.zhzf.fpj.xcx.api.demo.DemoProvider;
import com.zhzf.fpj.xcx.api.demo.DemoServiceOther; import com.zhzf.fpj.xcx.api.demo.DemoProviderOther;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -17,14 +17,14 @@ public class DemoConsumerController { ...@@ -17,14 +17,14 @@ public class DemoConsumerController {
application = "${dubbo.application.id}", application = "${dubbo.application.id}",
registry = "${dubbo.registry.id}", registry = "${dubbo.registry.id}",
check = false ) check = false )
private DemoService demoService; private DemoProvider demoService;
@Reference(version = "1.0.0", @Reference(version = "1.0.0",
application = "${dubbo.application.id}", application = "${dubbo.application.id}",
registry = "${dubbo.registry.id}", registry = "${dubbo.registry.id}",
check = false ) check = false )
private DemoServiceOther demoServiceOther; private DemoProviderOther demoServiceOther;
@RequestMapping("/sayHello") @RequestMapping("/sayHello")
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!