Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
武汉红喜
whatsmars
提交
1ee5dae2
W
whatsmars
项目概览
武汉红喜
/
whatsmars
通知
3
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
whatsmars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1ee5dae2
编写于
12月 03, 2019
作者:
武汉红喜
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
whatsmars-spring-data
上级
864dbe7c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
151 addition
and
0 deletion
+151
-0
whatsmars-spring-data/pom.xml
whatsmars-spring-data/pom.xml
+31
-0
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/Application.java
...in/java/org/hongxi/whatsmars/spring/data/Application.java
+16
-0
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/EsConfiguration.java
.../hongxi/whatsmars/spring/data/config/EsConfiguration.java
+33
-0
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/PropertyConfiguration.java
...i/whatsmars/spring/data/config/PropertyConfiguration.java
+19
-0
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/RedisConfiguration.java
...ngxi/whatsmars/spring/data/config/RedisConfiguration.java
+31
-0
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/service/DataService.java
...org/hongxi/whatsmars/spring/data/service/DataService.java
+16
-0
whatsmars-spring-data/src/main/resources/application-test.properties
...pring-data/src/main/resources/application-test.properties
+5
-0
未找到文件。
whatsmars-spring-data/pom.xml
0 → 100644
浏览文件 @
1ee5dae2
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<parent>
<artifactId>
whatsmars-parent
</artifactId>
<groupId>
org.hongxi
</groupId>
<version>
Rocket.S7
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
whatsmars-spring-data
</artifactId>
<dependencies>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-elasticsearch
</artifactId>
</dependency>
<dependency>
<groupId>
org.hongxi
</groupId>
<artifactId>
whatsmars-common
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/Application.java
0 → 100644
浏览文件 @
1ee5dae2
package
org.hongxi.whatsmars.spring.data
;
import
org.hongxi.whatsmars.common.profile.ProfileUtils
;
import
org.hongxi.whatsmars.spring.data.config.PropertyConfiguration
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
context
.
register
(
PropertyConfiguration
.
class
);
context
.
scan
(
"org.hongxi.whatsmars.spring.data"
);
context
.
getEnvironment
().
setActiveProfiles
(
ProfileUtils
.
getProfile
());
context
.
refresh
();
}
}
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/EsConfiguration.java
0 → 100644
浏览文件 @
1ee5dae2
package
org.hongxi.whatsmars.spring.data.config
;
import
org.elasticsearch.client.transport.TransportClient
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.elasticsearch.client.TransportClientFactoryBean
;
import
java.util.Properties
;
@Configuration
public
class
EsConfiguration
{
@Value
(
"${es.cluster.name}"
)
private
String
clusterName
;
@Value
(
"${es.cluster.nodes}"
)
private
String
clusterNodes
;
@Bean
public
TransportClient
transportClient
()
throws
Exception
{
TransportClientFactoryBean
factory
=
new
TransportClientFactoryBean
();
factory
.
setClusterNodes
(
clusterNodes
);
factory
.
setProperties
(
createProperties
());
factory
.
afterPropertiesSet
();
return
factory
.
getObject
();
}
private
Properties
createProperties
()
{
Properties
properties
=
new
Properties
();
properties
.
put
(
"cluster.name"
,
clusterName
);
return
properties
;
}
}
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/PropertyConfiguration.java
0 → 100644
浏览文件 @
1ee5dae2
package
org.hongxi.whatsmars.spring.data.config
;
import
org.hongxi.whatsmars.common.profile.ProfileUtils
;
import
org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.ClassPathResource
;
@Configuration
public
class
PropertyConfiguration
{
@Bean
public
PropertyPlaceholderConfigurer
configurer
()
{
PropertyPlaceholderConfigurer
configurer
=
new
PropertyPlaceholderConfigurer
();
String
path
=
String
.
format
(
"application-%s.properties"
,
ProfileUtils
.
getProfile
());
configurer
.
setLocation
(
new
ClassPathResource
(
path
));
return
configurer
;
}
}
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/config/RedisConfiguration.java
0 → 100644
浏览文件 @
1ee5dae2
package
org.hongxi.whatsmars.spring.data.config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.connection.jedis.JedisConnectionFactory
;
import
org.springframework.data.redis.core.RedisTemplate
;
@Configuration
public
class
RedisConfiguration
{
@Value
(
"${redis.host}"
)
private
String
hostName
;
@Value
(
"${redis.port}"
)
private
int
port
;
@Bean
public
RedisTemplate
redisTemplate
(
JedisConnectionFactory
jedisConnectionFactory
)
{
RedisTemplate
redisTemplate
=
new
RedisTemplate
();
redisTemplate
.
setConnectionFactory
(
jedisConnectionFactory
);
return
redisTemplate
;
}
@Bean
public
JedisConnectionFactory
jedisConnectionFactory
()
{
JedisConnectionFactory
connectionFactory
=
new
JedisConnectionFactory
();
connectionFactory
.
setHostName
(
hostName
);
connectionFactory
.
setPort
(
port
);
return
connectionFactory
;
}
}
whatsmars-spring-data/src/main/java/org/hongxi/whatsmars/spring/data/service/DataService.java
0 → 100644
浏览文件 @
1ee5dae2
package
org.hongxi.whatsmars.spring.data.service
;
import
org.elasticsearch.client.transport.TransportClient
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
@Service
public
class
DataService
{
@Resource
private
RedisTemplate
<
Integer
,
String
>
redisTemplate
;
@Resource
private
TransportClient
transportClient
;
}
whatsmars-spring-data/src/main/resources/application-test.properties
0 → 100644
浏览文件 @
1ee5dae2
redis.host
=
127.0.0.1
redis.port
=
6379
es.cluster.name
=
elasticsearch
es.cluster.nodes
=
127.0.0.1:9300
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录