Skip to content

Commit d0e943a

Browse files
author
quding
committed
增加 Dubbo-Demo
1 parent 93b4c65 commit d0e943a

File tree

29 files changed

+569
-0
lines changed

29 files changed

+569
-0
lines changed

Dubbo-Demo/Service-Client/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>cn.mrdear.dubbo</groupId>
7+
<artifactId>Dubbo-Demo</artifactId>
8+
<version>1.0.0</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
<artifactId>Service-Client</artifactId>
12+
13+
14+
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.mrdear.client.dto;
2+
3+
/**
4+
* @author Niu Li
5+
* @since 2017/6/12
6+
*/
7+
public class UserDTO {
8+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package cn.mrdear.client.service;
2+
3+
import cn.mrdear.client.dto.UserDTO;
4+
5+
import java.util.Collection;
6+
import java.util.List;
7+
8+
/**
9+
* 用户服务
10+
* @author Niu Li
11+
* @since 2017/6/12
12+
*/
13+
public interface IUserService {
14+
15+
/**
16+
* 根据id查找
17+
*/
18+
UserDTO findById(Long id);
19+
20+
/**
21+
* 根据id批量查询
22+
*/
23+
List<UserDTO> queryByIds(Collection<Long> ids);
24+
25+
/**
26+
* 更新用户
27+
* @return 返回更新后的实体
28+
*/
29+
UserDTO updateById(UserDTO userDTO);
30+
31+
32+
}

Dubbo-Demo/Service-Consumer/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>cn.mrdear.dubbo</groupId>
7+
<artifactId>Dubbo-Demo</artifactId>
8+
<version>1.0.0</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
<artifactId>Service-Consumer</artifactId>
12+
13+
14+
</project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package cn.mrdear.consumer.manager.impl;
2+
3+
/**
4+
* manager
5+
* @author Niu Li
6+
* @since 2017/6/13
7+
*/
8+
9+
public interface UserManager {
10+
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package cn.mrdear.consumer.manager;
2+
3+
/**
4+
* @author Niu Li
5+
* @since 2017/6/13
6+
*/
7+
public class UserManagerImpl {
8+
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:context="http://www.springframework.org/schema/context"
5+
xmlns:task="http://www.springframework.org/schema/task"
6+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
7+
8+
<!-- 启用注解 -->
9+
<context:annotation-config/>
10+
<!--启动定时器-->
11+
<task:annotation-driven/>
12+
13+
<context:component-scan base-package="cn.mrdear.consumer"/>
14+
15+
</beans>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.mrdear.test;
2+
3+
/**
4+
* @author Niu Li
5+
* @since 2017/6/13
6+
*/
7+
public class UserManagerTest {
8+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:context="http://www.springframework.org/schema/context"
5+
xmlns:task="http://www.springframework.org/schema/task"
6+
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
7+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
8+
9+
<!-- 启用注解 -->
10+
<context:annotation-config/>
11+
<!--启动定时器-->
12+
<task:annotation-driven/>
13+
14+
<context:component-scan base-package="cn.mrdear.consumer"/>
15+
16+
17+
<!-- 提供方应用信息,用于计算依赖关系 -->
18+
<dubbo:application name="user_consumer" />
19+
20+
<!-- 使用zookeeper注册中心暴露服务地址 -->
21+
<dubbo:registry address="zookeeper://127.0.0.1:2181" />
22+
23+
<!-- 声明需要暴露的服务接口 -->
24+
<dubbo:reference interface="cn.mrdear.client.service.IUserService" id="userService"
25+
check="false" />
26+
27+
</beans>

Dubbo-Demo/Service-Provider/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>cn.mrdear.dubbo</groupId>
7+
<artifactId>Dubbo-Demo</artifactId>
8+
<version>1.0.0</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
<artifactId>Service-Provider</artifactId>
12+
13+
14+
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.mrdear.provider;
2+
3+
/**
4+
* @author Niu Li
5+
* @since 2017/6/12
6+
*/
7+
public class Application {
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.mrdear.provider.convert;
2+
3+
/**
4+
* @author Niu Li
5+
* @since 2017/6/12
6+
*/
7+
public class UserConvert {
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.mrdear.provider.dao;
2+
3+
/**
4+
* @author Niu Li
5+
* @since 2017/6/12
6+
*/
7+
public class UserRepository {
8+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package cn.mrdear.provider.domain;
2+
3+
import lombok.Data;
4+
5+
import javax.persistence.Entity;
6+
import javax.persistence.GeneratedValue;
7+
import javax.persistence.Id;
8+
import javax.persistence.Table;
9+
10+
import java.io.Serializable;
11+
12+
/**
13+
* 用户实体类,对应数据库
14+
* @author Niu Li
15+
* @since 2017/6/12
16+
*/
17+
@Data
18+
@Entity
19+
@Table(name = "user")
20+
public class UserDO implements Serializable{
21+
22+
private static final long serialVersionUID = 1793488098966504793L;
23+
@Id
24+
@GeneratedValue
25+
private Long id;
26+
27+
private String username;
28+
29+
private String password;
30+
31+
private Integer age;
32+
33+
private String nickname;
34+
35+
private String mail;
36+
37+
private String memo;
38+
39+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.mrdear.provider.service;
2+
3+
/**
4+
* @author Niu Li
5+
* @since 2017/6/12
6+
*/
7+
public class UserService {
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
5+
6+
</beans>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
jdbc.driver=com.mysql.jdbc.Driver
2+
jdbc.url=jdbc:mysql://115.159.185.14:3306/ssm?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
3+
jdbc.username=root
4+
jdbc.password=7946521
5+
6+
filters:stat
7+
8+
maxActive:20
9+
initialSize:1
10+
maxWait:60000
11+
minIdle:10
12+
13+
timeBetweenEvictionRunsMillis:60000
14+
minEvictableIdleTimeMillis:300000
15+
16+
testWhileIdle:true
17+
testOnBorrow:false
18+
testOnReturn:false
19+
20+
maxOpenPreparedStatements:20
21+
removeAbandoned:true
22+
removeAbandonedTimeout:1800
23+
logAbandoned:true

Dubbo-Demo/Service-Provider/src/main/resources/h2/data.sql

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
drop table user if exists;
2+
create table user (
3+
id INT(11) AUTO_INCREMENT PRIMARY KEY ,
4+
username VARCHAR(255),
5+
password VARCHAR(255),
6+
age INT(3),
7+
nickname VARCHAR(255),
8+
mail VARCHAR(255),
9+
memo VARCHAR(255),
10+
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
4+
<property name="LOG_HOME" value="logs" />
5+
6+
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
7+
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
8+
<pattern>%d{HH:mm:ss} [%t] %logger{5} [%line] %p - %msg%n</pattern>
9+
</encoder>
10+
</appender>
11+
12+
<!-- project level -->
13+
<logger name="cn.mrdear" level="DEBUG" />
14+
15+
<root level="DEBUG" >
16+
<appender-ref ref="console" />
17+
</root>
18+
19+
</configuration>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package cn.mrdear.test;
2+
3+
/**
4+
* @author Niu Li
5+
* @since 2017/6/13
6+
*/
7+
public class UserServiceTest {
8+
}

0 commit comments

Comments
 (0)