基于微服务的用户注册时的手机短信验证码,这里将短信验证码的第三方接口(阿里云提供)封装成一个工具类
截图:
示例
1.工程结构:
2.crowd-common子模块中:
(1).RedisProviderService.java:
import com.kmu.util.ResultEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
public interface RedisProviderService {
//存
@RequestMapping("/save/string")
ResultEntity<String> saveNormalStringKeyValue(
@RequestParam("normalKey") String normalKey,
@RequestParam("normalValue") String normalValue,
@RequestParam("timeoutMinute") Integer timeoutMinute);
//取
@RequestMapping("/retrieve/string")
ResultEntity<String> retrieveStringValueByStringKey(@RequestParam("normalKey") String normalKey);
//删除
@RequestMapping("/remove/string")
ResultEntity<String> removeByKey(@RequestParam("key") String key);
}
(2).Member.java:
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
@TableName("t_member")
public class Member implements Serializable{
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String loginacct;
private String userpswd;
private String username;
private String email;
/**
* 实名认证状态 0 - 未实名认证, 1 - 实名认证申请中, 2 - 已实名认证
*/
private Integer authstatus;
/**
* 0 - 个人, 1 - 企业
*/
private Integer usertype;
private String realname;
private String cardnum;
/**
* 0 - 企业, 1 - 个体, 2 - 个人, 3 - 政府
*/
private Integer accttype;
private String phonenum;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getLoginacct() {
return loginacct;
}
public void setLoginacct(String loginacct) {
this.loginacct = loginacct;
}
public String getUserpswd() {
return userpswd;
}
public void setUserpswd(String userpswd) {
this.userpswd = userpswd;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getAuthstatus() {
return authstatus;
}
public void setAuthstatus(Integer authstatus) {
this.authstatus = authstatus;
}
public Integer getUsertype() {
return usertype;
}
public void setUsertype(Integer usertype) {
this.usertype = usertype;
}
public String getRealname() {
return realname;
}
public void setRealname(String realname) {
this.realname = realname;
}
public String getCardnum() {
return cardnum;
}
public void setCardnum(String cardnum) {
this.cardnum = cardnum;
}
public Integer getAccttype() {
return accttype;
}
public void setAccttype(Integer accttype) {
this.accttype = accttype;
}
public String getPhonenum() {
return phonenum;
}
public void setPhonenum(String phonenum) {
this.phonenum = phonenum;
}
@Override
public String toString() {
return "Member{" +
", id=" + id +
", loginacct=" + loginacct +
", userpswd=" + userpswd +
", username=" + username +
", email=" + email +
", authstatus=" + authstatus +
", usertype=" + usertype +
", realname=" + realname +
", cardnum=" + cardnum +
", accttype=" + accttype +
", phonenum=" + phonenum +
"}";
}
}
(3).Constants.java
/**
* 常量类,封装项目中用到的各种常量
*/
public class Constants {
public static final String SHOT_MESSAGE_PRIFX="SHOT_MESSAGE_";
}
(4).ResultEntity.java
public class ResultEntity<T> {
//常量
public static final String CODE_SUCCESS="SUCCESS";
public static final String CODE_FAILED="FAILED";
//设定状态码,前端根据状态码,判断成功、失败的响应
private String code;
//返回的消息
private String msg;
//回显的数据
T data;
//成功,并返回消息
public static ResultEntity successWithData(Object data){
ResultEntity<Object> tResultEntity = new ResultEntity<>();
tResultEntity.code=CODE_SUCCESS;
tResultEntity.setData(data);
return tResultEntity;
}
//失败,并返回消息
public static ResultEntity failedWithData(Object data){
ResultEntity<Object> tResultEntity = new ResultEntity<>();
tResultEntity.code=CODE_FAILED;
tResultEntity.setData(data);
return tResultEntity;
}
//成功,并返回消息
public static ResultEntity successWithData(String msg,Object data){
ResultEntity<Object> tResultEntity = new ResultEntity<>();
tResultEntity.code=CODE_SUCCESS;
tResultEntity.setMsg(msg);
tResultEntity.setData(data);
return tResultEntity;
}
//失败,并返回消息
public static ResultEntity failedWithData(String msg,Object data){
ResultEntity<Object> tResultEntity = new ResultEntity<>();
tResultEntity.code=CODE_FAILED;
tResultEntity.setMsg(msg);
tResultEntity.setData(data);
return tResultEntity;
}
//成功
public static ResultEntity success(){
ResultEntity<Object> tResultEntity = new ResultEntity<>();
tResultEntity.code=CODE_SUCCESS;
return tResultEntity;
}
//失败
public static ResultEntity failed(){
ResultEntity<Object> tResultEntity = new ResultEntity<>();
tResultEntity.code=CODE_FAILED;
return tResultEntity;
}
public ResultEntity() {
super();
}
public ResultEntity(String code, String msg, T data) {
this.code = code;
this.msg = msg;
this.data = data;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
(5).SendSms.java
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
/**
* 将短信验证码的第三接口封装成一个工具类
*/
public class SendSms {
/**
* @param signName 签名
* @param TemplateCode 模版
* @param PhoneNumbers 手机号
* @param TemplateParam 验证码
*/
public static void sendSms(String signName,String TemplateCode,String PhoneNumbers,String TemplateParam ){
//声明一些配置信息
DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "自己在阿里云申请的签名的 accessKeyId", "申请的签名的secret");
IAcsClient client = new DefaultAcsClient(profile);
//创建一个请求对象
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);
request.setSysDomain("dysmsapi.aliyuncs.com");
request.setSysVersion("2017-05-25");
request.setSysAction("SendSms");
request.putQueryParameter("RegionId", "cn-hangzhou");
request.putQueryParameter("PhoneNumbers", PhoneNumbers);
request.putQueryParameter("SignName", signName);
//SMS_197395293
request.putQueryParameter("TemplateCode", TemplateCode);
request.putQueryParameter("TemplateParam", "{\"code\":\""+TemplateParam+"\"}");
try {
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
} catch (Exception e) {
e.printStackTrace();
}
}
}
3.crowd-eureka子模块
(1).CrowdEurekaApplication.java主启动类:
@SpringBootApplication
@EnableEurekaServer
public class CrowdEurekaApplication {
public static void main(String[] args) {
SpringApplication.run(CrowdEurekaApplication.class, args);
}
}
(2).application.yml
server:
port: 7001
eureka:
instance:
hostname: eureka01.com
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
4.crowd-redis-provider子模块:
(1).RedisController.java
/**
* 当前项目中,关于redis,主要就是进行缓存、springsession存储数据的中心
* 没有特殊的需求,用字符串类型就够了!!
* 所以,这里,我们提提供针对redis的字符串的增删改查方法就可以
* 将来其他服务能够调用,使用就可以了!!!!
*
*/
@RestController
public class RedisController {
/*
spring data,spring针对数据提供的一系列框架!!!
spring data jpa
spring data jdbc
spring data redis
提供了RedisTemplate,封装了关于redis的基本操作,我们通过调用它实现基本的增删改查
*/
@Autowired
RedisTemplate redisTemplate;
//http://localhost:5001/save/string?normalKey=ceo&normalValue=zhangsan&timeoutMinute=1
@RequestMapping("/save/string")
ResultEntity<String> saveNormalStringKeyValue(
@RequestParam("normalKey") String normalKey,
@RequestParam("normalValue") String normalValue,
@RequestParam("timeoutMinute") Integer timeoutMinute) {
// 获取字符串操作器对象
ValueOperations<String, String> operator = redisTemplate.opsForValue();
// 判断timeoutMinute值:是否为不设置过期时间
if(timeoutMinute == -1) {
// 按照不设置过期时间的方式执行保存
operator.set(normalKey, normalValue);
// 返回结果
}else
// 按照设置过期时间的方式执行保存
operator.set(normalKey, normalValue, timeoutMinute, TimeUnit.MINUTES);
return ResultEntity.success();
}
/**
* 根据key查询对应value时调用的远程方法
* @param normalKey
* @return
*/
@RequestMapping("/retrieve/string")
ResultEntity<String> retrieveStringValueByStringKey(@RequestParam("normalKey") String normalKey) {
String value = (String) redisTemplate.opsForValue().get(normalKey);
return ResultEntity.successWithData("查询成功",value);
}
/**
* 根据key删除对应value时调用的远程方法
* @param key
* @return
*/
//http://localhost:5001/remove/string?key=ceo1
@RequestMapping("/remove/string")
ResultEntity<String> removeByKey(@RequestParam("key") String key) {
redisTemplate.delete(key);
return ResultEntity.success();
}
}
(2).CrowdRedisProviderApplication.java主启动类
@SpringBootApplication
@EnableEurekaClient
public class CrowdRedisProviderApplication {
public static void main(String[] args) {
SpringApplication.run(CrowdRedisProviderApplication.class, args);
}
}
(3).application.yml
server:
port: 5001
spring:
application:
name: redis-provider
redis:
host: localhost
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka/
instance:
prefer-ip-address: true
5.crowd-web子模块:
(1).MVCConfig.java
@Configuration
public class MVCConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/reg.html").setViewName("/reg");
}
}
(2).MemberController.java
/**
* 和网站注册会员相关的控制器
*/
@Controller
@RequestMapping("/web")
public class MemberController {
@Autowired
RedisProviderServiceExtends redisProviderServiceExtends;
//发送手机短信验证码
@PostMapping("/sendMsg.json")
@ResponseBody
public ResultEntity sendMsg(String phoneNum){
try{
//生成一个6位的随机短信验证码
int randomInt = RandomUtil.randomInt(100000, 999999);
//发送redis去存储
/**
* 阿里云提供的第三方短信验证接口
* 参数1:签名
* 参数2:模板
* 参数3:手机号
* 参数4:验证码
*/
redisProviderServiceExtends.saveNormalStringKeyValue(Constants.SHOT_MESSAGE_PRIFX+phoneNum,randomInt+"",1);
//为phoneNum 发送验证
SendSms.sendSms("ABC商城","SMS_198670400",phoneNum,randomInt+"");
//响应结果给页面
return ResultEntity.success();
}catch (Exception e){
return ResultEntity.failed();
}
}
}
(3).RedisProviderServiceExtends.java
import com.kmu.api.RedisProviderService;
import org.springframework.cloud.openfeign.FeignClient;
/**
* Redis服务的接口的扩展接口
*/
@FeignClient("redis-provider")
public interface RedisProviderServiceExtends extends RedisProviderService {
}
(4).CrowdWebApplication.java主启动类
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
public class CrowdWebApplication {
public static void main(String[] args) {
SpringApplication.run(CrowdWebApplication.class, args);
}
}
(5).application.yml
server:
port: 80
spring:
application:
name: crowd_web
# redis配置
redis:
host: localhost
jedis:
pool:
max-idle: 100
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka/
instance:
prefer-ip-address: true
---
server:
port: 80
spring:
profiles: 80
---
server:
port: 81
spring:
profiles: 81
(6).reg.html模板引擎中:
代码:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="keys" content="">
<meta name="author" content="">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/login.css">
<style>
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<div><a class="navbar-brand" href="index.html" style="font-size:32px;">众筹网-创意产品众筹平台</a></div>
</div>
</div>
</nav>
<div class="container">
<form class="form-signin" role="form">
<h2 class="form-signin-heading"><i class="glyphicon glyphicon-log-in"></i> 用户注册</h2>
<div class="form-group has-success has-feedback">
<input type="text" class="form-control" id="username" placeholder="请输入登录账号" autofocus>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-success has-feedback">
<input type="text" class="form-control" id="password" placeholder="请输入登录密码" style="margin-top:10px;">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="form-group has-success has-feedback">
<input type="text" class="form-control" id="phoneNum" placeholder="请输入手机号" style="margin-top:10px;">
<span class="glyphicon glyphicon-phone form-control-feedback"></span>
</div>
<div class=" form-group has-success has-feedback ">
<input type="text" class="form-control" id="inputSuccess4" placeholder="请输入验证码" style="margin-top:10px;">
<span class="glyphicon glyphicon-phone form-control-feedback"></span>
</div >
<div class="form-group ">
<button id="sendMsg" type="button" class="btn form-control btn-success" >发送</button>
</div>
<div class="form-group has-success has-feedback">
<select class="form-control" >
<option>企业</option>
<option>个人</option>
</select>
</div>
<div class="checkbox">
<label>
忘记密码
</label>
<label style="float:right">
<a href="login.html">我有账号</a>
</label>
</div>
<button type="button" class="btn btn-lg btn-success btn-block" href="member.html" > 注册</button>
</form>
</div>
<script src="jquery/jquery-2.1.1.min.js"></script>
<script src="layer/layer.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script>
$(function () {
//sendMsg给绑定点击事件,发送短信验证码
$("#sendMsg").click(function () {
//获取#phoneNum的值,去发送
var phoneNum=$("#phoneNum").val();
if(phoneNum.length != 11){
layer.msg("手机号格式不正确,请重新输入!");
}else{
//异步请求web服务,去发送短信
$.ajax({
url:"[[@{/web/sendMsg.json}]]",
data:{"phoneNum":phoneNum},
dataType:"JSON",
type:"POST",
success:function(result){
layer.msg("发送成功,验证码1分钟内有效!");
}
});
}
});
});
</script>
</body>
</html>
验证码的校验
6.pom.xml文件
(1).kmu-crowd-parent父工程
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.kmu</groupId>
<artifactId>kmu-crowd-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<!--聚合子模块-->
<modules>
<!-- <module>mybatis-generator</module>-->
<module>crowd-common</module>
<module>crowd-database-provider</module>
<module>crowd-eureka</module>
<module>crowd-member-manager</module>
<module>crowd-project-manager</module>
<module>crowd-redis-provider</module>
<module>crowd-web</module>
</modules>
<packaging>pom</packaging>
<name>Maven</name>
<!-- FIXME change it to the project's website -->
<url>http://maven.apache.org/</url>
<inceptionYear>2001</inceptionYear>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- SpringBoot -->
<spring-boot.version>2.3.1.RELEASE</spring-boot.version>
<spring-boot-starter-test>2.3.1.RELEASE</spring-boot-starter-test>
<!-- SpringCloud -->
<spring-cloud.version>Hoxton.SR6</spring-cloud.version>
<!-- junit -->
<junit.version>4.12</junit.version>
<!-- 时间日期操作 -->
<joda-time.version>2.9.9</joda-time.version>
<!-- httpclient -->
<httpclient.version>4.5.3</httpclient.version>
<!-- 功能组件 -->
<poi.version>3.16</poi.version>
<quartz.version>2.2.3</quartz.version>
<!-- 数据库和数据库连接池 -->
<druid.version>1.1.0</druid.version>
<mysql.connector>5.1.42</mysql.connector>
<!-- 基础框架 -->
<spring.version>5.2.6.RELEASE</spring.version>
<mybatis-plus-boot-starter>3.3.2</mybatis-plus-boot-starter>
<!-- 日志 -->
<log4j.version>1.2.17</log4j.version>
<slf4j.version>1.7.6</slf4j.version>
<logback.version>1.2.3</logback.version>
<!-- servlet-api,jsp-api,jstl -->
<servlet-api.version>2.5</servlet-api.version>
<jsp-api.version>2.2</jsp-api.version>
<jstl.version>1.2</jstl.version>
<!--阿里云短信验证依赖-->
<aliyun-java-sdk-core>4.4.6</aliyun-java-sdk-core>
<aliyun-java-sdk-ecs>4.17.6</aliyun-java-sdk-ecs>
</properties>
<!-- 依赖管理 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.10</version>
</dependency>
<!--阿里云短信验证依赖-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>${aliyun-java-sdk-core}</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-ecs</artifactId>
<version>${aliyun-java-sdk-ecs}</version>
</dependency>
<!-- SpringBoot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- SpringCloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-starter-test}</version>
</dependency>
<!-- 时间日期 -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
<!-- httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<!-- jedis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- 基础框架 -->
<!-- mybatis plus配置 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus-boot-starter}</version>
</dependency>
<!-- 基础框架完成 -->
<!-- 日志 -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- 依赖的WEB类库 -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>${jsp-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.15</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>9.3.7.v20160115</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
(2).crowd-common子模块
<?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>kmu-crowd-parent</artifactId>
<groupId>com.kmu</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>crowd-common</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<!-- 导入mybatis plus的starter,会出事故
其他引入common的工程,如果是springboot工程,是不是能够自动检测到mybatis plus的starter
就会初始化,需要mysql的连接信息!!!!而你在这里没有配置!!!!!
所以,在启动时,就会报错!!说database url找不到!!!!!!
解决方案:我们在当前common中,用到的仅仅是mybatisplus的哪些注解,并不是stater!!!!
所以,你只需要引入mybatis plus的注解annotaion包就可以!!!!-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-ecs</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
(2).crowd-eureka子模块
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>crowd-eureka</artifactId>
<name>crowd-eureka</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>com.kmu</groupId>
<artifactId>kmu-crowd-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
(4).crowd-redis-provider子模块
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>crowd-redis-provider</artifactId>
<name>crowd-redis-provider</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>com.kmu</groupId>
<artifactId>kmu-crowd-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<artifactId>crowd-common</artifactId>
<groupId>com.kmu</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
(5).crowd-web子模块
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>crowd-web</artifactId>
<name>crowd-web</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>com.kmu</groupId>
<artifactId>kmu-crowd-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<!--引入openFegin-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<!-- 引入redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- 引入springsession-->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alipay.sdk/alipay-sdk-java -->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.10.70.ALL</version>
</dependency>
<dependency>
<artifactId>crowd-common</artifactId>
<groupId>com.kmu</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>