增加Spring cloud config和spring cloud bus配置,迁移配置文件到gitee,增加rabbitmq和bus的整合

main
wangqing 11 months ago
parent 8203992415
commit a0cbe07167

@ -29,6 +29,22 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>

@ -1,19 +0,0 @@
server:
port: 9006
spring:
application:
name: luoo-comment
data:
mongodb:
uri: mongodb://8.134.98.47:27017/spitdb
username: root
password: 47084735Abc@
redis:
host: 8.134.98.47
port: 36379
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:6868/eureka/
instance:
prefer-ip-address: true

@ -0,0 +1,7 @@
spring:
cloud:
config:
name: comment
profile: dev
label: master
uri: http://127.0.0.1:12000

@ -0,0 +1,33 @@
<?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>luoo_parent</artifactId>
<groupId>com.luoo</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>luoo_config</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

@ -0,0 +1,13 @@
package com.luoo.config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class ConfigApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigApplication.class);
}
}

@ -0,0 +1,19 @@
server:
port: 12000
spring:
application:
name: luoo-config
cloud:
config:
server:
git:
uri: https://gitee.com/sinkids/luoo_dev.git
username: sinkids
password: 47084735abc
rabbitmq:
host: 116.62.145.60
management:
endpoints:
web:
exposure:
include: bus-refresh

@ -22,6 +22,22 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>

@ -1,8 +0,0 @@
server:
port: 6868
eureka:
client:
register-with-eureka: false
fetch-registry: true
service-url:
defaultZone: http://127.0.0.1:${server.port}/eureka/

@ -0,0 +1,7 @@
spring:
cloud:
config:
name: eureka
profile: dev
label: master
uri: http://127.0.0.1:12000

@ -40,5 +40,21 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
</project>

@ -1,23 +0,0 @@
server:
port: 9010
spring:
application:
name: luoo-friend
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://8.134.98.47:3307/indie_friend?characterEncoding=UTF8&useSSL=false
username: root
password: 47084735abc
jpa:
database: MySQL
show-sql: true
jwt:
config:
key: luoo
ttl: 3600000
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:6868/eureka/
instance:
prefer-ip-address: true

@ -0,0 +1,7 @@
spring:
cloud:
config:
name: friend
profile: dev
label: master
uri: http://127.0.0.1:12000

@ -26,6 +26,22 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.luoo</groupId>
<artifactId>luoo_common</artifactId>

@ -1,25 +0,0 @@
server:
port: 9011
spring:
application:
name: luoo-manage
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:6868/eureka/
instance:
prefer-ip-address: true
jwt:
config:
key: luoo
zuul:
routes:
luoo-user:
path: /user/**
serviceId: luoo-user
luoo-gathering:
path: /gathering/**
serviceId: luoo-gathering
luoo-music:
path: /article/**
serviceId: luoo-music

@ -0,0 +1,7 @@
spring:
cloud:
config:
name: manage
profile: dev
label: master
uri: http://127.0.0.1:12000

@ -32,6 +32,22 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>

@ -1,22 +0,0 @@
server:
port: 9004
spring:
application:
name: luoo-music #指定服务名
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://8.134.98.47:3307/indie_music?characterEncoding=UTF8&useSSL=false
username: root
password: 47084735abc
jpa:
database: MySQL
show-sql: true
redis:
host: 8.134.98.47
port: 36379
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:6868/eureka/
instance:
prefer-ip-address: true

@ -0,0 +1,7 @@
spring:
cloud:
config:
name: music
profile: dev
label: master
uri: http://127.0.0.1:12000

@ -15,6 +15,22 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>

@ -1,13 +0,0 @@
server:
port: 9009
spring:
application:
name: luoo-sms
rabbitmq:
host: 116.62.145.60
aliyun:
sms:
accessKeyId: xxx
accessKeySecret: xxx
template_code: xxx
sign_name: xxx

@ -0,0 +1,7 @@
spring:
cloud:
config:
name: sms
profile: dev
label: master
uri: http://127.0.0.1:12000

@ -40,6 +40,22 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>

@ -72,6 +72,28 @@ public class UserController {
return new Result(true,StatusCode.OK,"登录成功",map);
}
@RequestMapping(value = "/appLogin/{mobile}/{checkcode}",method = RequestMethod.POST)
public Result appLogin(@PathVariable String mobile,@PathVariable String checkcode){
// 得到缓存中的验证码
String checkcodeRedis = (String)redisTemplate.opsForValue().get("checkcode_"+mobile);
if (checkcodeRedis.isEmpty()){
return new Result(false,StatusCode.ERROR,"请先获取手机验证码");
}
if (!checkcodeRedis.equals(checkcode)) {
return new Result(false,StatusCode.ERROR,"请输入正确的验证码");
}
User user = userService.findByMobile(mobile);
// 如果数据库中有这个手机号,登录通道,
if (user != null){
String token = jwtUtil.createJWT(user.getId(),user.getMobile(),"user");
}
// 如果数据库中没有这个手机号,为新用户,注册添加用户
return new Result(true,StatusCode.OK,"登录成功");}
/**
*
*/

@ -236,4 +236,8 @@ public class UserService {
userDao.updatefollowcount(x,userid);
}
public User findByMobile(String mobile) {
User user = userDao.findByMobile(mobile);
return user;
}
}

@ -1,28 +0,0 @@
server:
port: 9008
spring:
application:
name: luoo-user #指定服务名
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://8.134.98.47:3307/indie_user?characterEncoding=UTF8&useSSL=false
username: root
password: 47084735abc
jpa:
database: MySQL
show-sql: true
redis:
host: 116.62.145.60
rabbitmq:
host: 116.62.145.60
jwt:
config:
key: luoo
ttl: 3600000
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:6868/eureka/
instance:
prefer-ip-address: true

@ -0,0 +1,7 @@
spring:
cloud:
config:
name: user
profile: dev
label: master
uri: http://127.0.0.1:12000

@ -25,6 +25,22 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>

@ -1,22 +0,0 @@
server:
port: 9012
spring:
application:
name: luoo-web
eureka:
client:
service-url:
defaultZone: http://127.0.0.1:6868/eureka/
instance:
prefer-ip-address: true
zuul:
routes:
luoo-user:
path: /user/**
serviceId: luoo-user
luoo-music:
path: /article/**
serviceId: luoo-music
luoo-comment:
path: /comment/**
serviceId: luoo-comment

@ -0,0 +1,7 @@
spring:
cloud:
config:
name: web
profile: dev
label: master
uri: http://127.0.0.1:12000

@ -18,6 +18,7 @@
<module>luoo_manage</module>
<module>luoo_web</module>
<module>luoo_sms</module>
<module>luoo_config</module>
</modules>
<packaging>pom</packaging>
<name>luoo_parent</name>
@ -58,6 +59,10 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>

Loading…
Cancel
Save