Skip to content

Commit 60a3e89

Browse files
author
qianlq
committed
临时提交
1 parent d7aa5ef commit 60a3e89

File tree

12 files changed

+226
-1
lines changed

12 files changed

+226
-1
lines changed

dubbo-api/src/main/java/com/coderqian/dubboapi/service/TestService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ public interface TestService {
1515
* @return String
1616
*/
1717
String test(String text);
18+
19+
/**
20+
* 测试接口
21+
*
22+
* @param text 测试数据
23+
* @return String
24+
*/
25+
String testMybatis(String text);
1826
}

dubbo-provider/pom.xml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,33 @@
3535
<artifactId>spring-boot-starter-actuator</artifactId>
3636
</dependency>
3737

38-
<!-- Hystrix依赖 -->
38+
<!-- 引入Hystrix依赖 -->
3939
<dependency>
4040
<groupId>org.springframework.cloud</groupId>
4141
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
4242
<version>2.0.1.RELEASE</version>
4343
</dependency>
4444

45+
<!-- 引入Mybatis依赖 -->
46+
<dependency>
47+
<groupId>org.mybatis.spring.boot</groupId>
48+
<artifactId>mybatis-spring-boot-starter</artifactId>
49+
<version>1.3.2</version>
50+
</dependency>
51+
52+
<!-- 引入Druid依赖 -->
53+
<dependency>
54+
<groupId>com.alibaba</groupId>
55+
<artifactId>druid-spring-boot-starter</artifactId>
56+
<version>1.1.10</version>
57+
</dependency>
58+
59+
<!-- 引入MySQL连接依赖 -->
60+
<dependency>
61+
<groupId>mysql</groupId>
62+
<artifactId>mysql-connector-java</artifactId>
63+
</dependency>
64+
4565
<dependency>
4666
<groupId>org.apache.zookeeper</groupId>
4767
<artifactId>zookeeper</artifactId>
@@ -77,6 +97,13 @@
7797
</exclusion>
7898
</exclusions>
7999
</dependency>
100+
101+
<dependency>
102+
<groupId>org.projectlombok</groupId>
103+
<artifactId>lombok</artifactId>
104+
<version>1.18.0</version>
105+
<scope>provided</scope>
106+
</dependency>
80107
</dependencies>
81108

82109
<dependencyManagement>

dubbo-provider/src/main/java/com/coderqian/dubboprovider/DubboProviderApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.coderqian.dubboprovider;
22

33
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
4+
import org.mybatis.spring.annotation.MapperScan;
45
import org.springframework.boot.SpringApplication;
56
import org.springframework.boot.autoconfigure.SpringBootApplication;
67
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
78

89
@EnableDubbo
910
@EnableHystrix
1011
@SpringBootApplication
12+
@MapperScan("com.coderqian.dubboprovider.mapper")
1113
//@ImportResource({"classpath:dubbo/dubbo-provider.xml"})
1214
public class DubboProviderApplication {
1315

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.coderqian.dubboprovider.configuration.config;
2+
3+
import com.alibaba.druid.pool.DruidDataSource;
4+
import org.springframework.beans.factory.annotation.Value;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
import org.springframework.context.annotation.Primary;
8+
9+
import javax.sql.DataSource;
10+
11+
/**
12+
* @author qianliqing
13+
* @date 2019/1/18 6:52 PM
14+
* email: qianlq0824@gmail.com
15+
*/
16+
17+
@Configuration
18+
public class DruidDBConfig {
19+
20+
@Value("${spring.datasource.url}")
21+
private String dbUrl;
22+
23+
@Value("${spring.datasource.username}")
24+
private String username;
25+
26+
@Value("${spring.datasource.password}")
27+
private String password;
28+
29+
@Value("${spring.datasource.driver-class-name}")
30+
private String driverClassName;
31+
32+
@Value("${spring.datasource.initialSize}")
33+
private int initialSize;
34+
35+
@Value("${spring.datasource.minIdle}")
36+
private int minIdle;
37+
38+
@Value("${spring.datasource.maxActive}")
39+
private int maxActive;
40+
41+
@Bean
42+
@Primary
43+
public DataSource dataSource() {
44+
DruidDataSource datasource = new DruidDataSource();
45+
datasource.setUrl(dbUrl);
46+
datasource.setUsername(username);
47+
datasource.setPassword(password);
48+
datasource.setDriverClassName(driverClassName);
49+
datasource.setInitialSize(initialSize);
50+
datasource.setMinIdle(minIdle);
51+
datasource.setMaxActive(maxActive);
52+
return datasource;
53+
}
54+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.coderqian.dubboprovider.configuration.filter;
2+
3+
import com.alibaba.druid.support.http.WebStatFilter;
4+
5+
import javax.servlet.annotation.WebFilter;
6+
import javax.servlet.annotation.WebInitParam;
7+
8+
/**
9+
* Created by superlee on 2017/11/6.
10+
* 配置druid监控统计功能
11+
* Druid过滤器
12+
*/
13+
@WebFilter(filterName = "druidWebStatFilter", urlPatterns = "/*",
14+
initParams = {
15+
@WebInitParam(name = "exclusions", value = "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源
16+
}
17+
)
18+
public class DruidStatFilter extends WebStatFilter {
19+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.coderqian.dubboprovider.configuration.servlet;
2+
3+
import com.alibaba.druid.support.http.StatViewServlet;
4+
5+
import javax.servlet.annotation.WebInitParam;
6+
import javax.servlet.annotation.WebServlet;
7+
8+
/**
9+
* @author qianliqing
10+
* @date 2019-01-18 6:37 PM
11+
* mail: qianlq0824@gmail.com
12+
* <p>
13+
* 配置druid监控统计功能
14+
*/
15+
16+
@WebServlet(urlPatterns = "/druid/*",
17+
initParams = {
18+
@WebInitParam(name = "allow", value = "192.168.16.110,127.0.0.1"), // IP白名单 (没有配置或者为空,则允许所有访问)
19+
@WebInitParam(name = "deny", value = "192.168.16.111"), // IP黑名单 (存在共同时,deny优先于allow)
20+
@WebInitParam(name = "loginUsername", value = "kBEuJPHmTgcVvKlt"),// 用户名
21+
@WebInitParam(name = "loginPassword", value = "zPhIJTa0jvsZ7sLj"),// 密码
22+
@WebInitParam(name = "resetEnable", value = "false")// 禁用HTML页面上的“Reset All”功能
23+
}
24+
)
25+
public class DruidStatViewServlet extends StatViewServlet {
26+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.coderqian.dubboprovider.mapper;
2+
3+
import com.coderqian.dubboprovider.model.entity.UserEntity;
4+
import org.apache.ibatis.annotations.Mapper;
5+
6+
import java.util.List;
7+
8+
/**
9+
* @author qianliqing
10+
* @date 2019/1/18 7:58 PM
11+
* email: qianliqing@hyperchain.com
12+
*/
13+
14+
@Mapper
15+
public interface UserMapper {
16+
17+
/**
18+
* 查询所有用户
19+
*
20+
* @return List<UserEntity>
21+
*/
22+
List<UserEntity> findAll();
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.coderqian.dubboprovider.model.entity;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* @author qianliqing
7+
* @date 2019/1/18 6:59 PM
8+
* email: qianlq0824@gmail.com
9+
*/
10+
11+
@Data
12+
public abstract class BaseEntity {
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.coderqian.dubboprovider.model.entity;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* @author qianliqing
7+
* @date 2019/1/18 6:59 PM
8+
* email: qianlq0824@gmail.com
9+
*/
10+
11+
@Data
12+
public class UserEntity extends BaseEntity {
13+
14+
private String id;
15+
16+
private String name;
17+
18+
private String birth;
19+
}

dubbo-provider/src/main/java/com/coderqian/dubboprovider/service/impl/TestServiceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public class TestServiceImpl implements TestService {
2323
public String test(@ApiParam(value = "测试数据", required = true) String text) {
2424
return text;
2525
}
26+
27+
@Override
28+
public String testMybatis(String text) {
29+
return null;
30+
}
2631
}

0 commit comments

Comments
 (0)