删除一堆生成javadoc的依赖,配置idea以及springboot热部署插件实现springboot项目的热部署

This commit is contained in:
lsy
2017-11-24 16:08:59 +08:00
parent 3f374ebdb0
commit 8abe367e8c
15 changed files with 224 additions and 131 deletions
@@ -41,18 +41,18 @@
<build>
<plugins>
<!--最终打成jar的时候一定要去掉此插件,不然依赖他的项目会找不到这个依赖-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
<!--</plugin>-->
</plugins>
<finalName>boot-starter-elasticsearch</finalName>
</build>
@@ -41,18 +41,18 @@
<build>
<plugins>
<!--最终打成jar的时候一定要去掉此插件,不然依赖他的项目会找不到这个依赖-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
<!--</plugin>-->
</plugins>
<finalName>boot-starter-fastdfs-client</finalName>
</build>
@@ -31,10 +31,10 @@
<build>
<plugins>
<!--最终打成jar的时候一定要去掉此插件,不然依赖他的项目会找不到这个依赖-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -35,10 +35,10 @@
<build>
<plugins>
<!--最终打成jar的时候一定要去掉此插件,不然依赖他的项目会找不到这个依赖-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -78,10 +78,10 @@
<build>
<plugins>
<!--最终打成jar的时候一定要去掉此插件,不然依赖他的项目会找不到这个依赖-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-maven-plugin</artifactId>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -27,6 +27,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
@@ -14,7 +14,6 @@ public class BootStarterSecurityDemoApplication {
}
@GetMapping("/hello")
public String hello(){
return "hello security";
return "hello security!!!!!";
}
}
@@ -23,7 +23,7 @@ public class MyInterceptor implements HandlerInterceptor {
System.out.println(((HandlerMethod) handler).getBean().getClass().getName());
//获取拦截的方法
System.out.println(((HandlerMethod) handler).getMethod().getName());
return false;
return true;
}
//** 请求之后,控制器中抛出了异常的话就不会执行
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
@Component
public class MyAspect {
@Pointcut("execution(* com.micro.fast.security.demo.controller.*(..))")
@Pointcut("execution(* com.micro.fast.security.demo.controller.RestfulController.*(..))")
public void pointcut(){
}
@@ -0,0 +1,54 @@
package com.micro.fast.security.demo.controller;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@RestController
@RequestMapping("/file")
public class FileController {
/**
* 处理文件上传
* @param file
*/
@PostMapping
public String upload(MultipartFile file){
File localfile = new File("/file/name");
try {
//将文件上传到本地路径
file.transferTo(localfile);
} catch (IOException e) {
e.printStackTrace();
}
String fileInfo = "";
fileInfo += file.getName()+file.getOriginalFilename()+file.getContentType();
return fileInfo;
}
/**
* 文件的下载
* @param id
* @param request
* @param response
*/
@GetMapping("/{id}")
public void download(@PathVariable String id , HttpServletRequest request, HttpServletResponse response){
try (InputStream inputStream = new FileInputStream(new File("/root/file/name"));
OutputStream outputStream = response.getOutputStream();
){
response.setContentType("application/x-download");
//指定文件的名称
response.addHeader("Content-Disposition","attachment;filename=test.txt");
IOUtils.copy(inputStream,outputStream);
outputStream.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -2,7 +2,7 @@ spring:
session:
store-type: none # 暂时不开启session存储
datasource:
url: jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=true
url: jdbc:mysql://172.17.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
username: root
password: studyj2e
driver-class-name: com.mysql.jdbc.Driver
@@ -6,6 +6,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@@ -21,44 +22,44 @@ import java.util.Date;
@SpringBootTest
public class BootStarterSecurityDemoApplicationTests {
@Test
public void contextLoads() {
}
@Test
public void contextLoads() {
}
@Autowired
private WebApplicationContext wac;
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
private MockMvc mockMvc;
/**
* 在每次测试执行前构建mvc环境
*/
@Before
public void setup(){
mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
}
/**
* 在每次测试执行前构建mvc环境
*/
@Before
public void setup() {
mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
}
/**
* 用户信息查询
*/
@Test
public void whenQuerySuccess(){
//测试接口的返回结果是否满足预期
try {
mockMvc.perform(MockMvcRequestBuilders.get("/user").param("username","pojo")
@Test
public void whenQuerySuccess() {
//测试接口的返回结果是否满足预期
try {
mockMvc.perform(MockMvcRequestBuilders.get("/user").param("username", "pojo")
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(MockMvcResultMatchers.status().isOk())//检查状态码
.andExpect(MockMvcResultMatchers.jsonPath("$.length()").value(3));//检查集合的长度是3个
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取用户的信息详情
*/
@Test
public void whenGetInfoSuccess(){
@Test
public void whenGetInfoSuccess() {
try {
mockMvc.perform(MockMvcRequestBuilders.get("/user/1")
.contentType(MediaType.APPLICATION_JSON_UTF8))
@@ -69,30 +70,51 @@ public class BootStarterSecurityDemoApplicationTests {
}
}
/**
* 创建用户
*/
@Test
public void whenCreateSuccess(){
//前台传入的是长整形
Date date = new Date();
String content = "{\"name\":\"tom\",\"password\":\"\",\"birthday\":"+date.getTime()+"}";
try {
String tom = mockMvc.perform(MockMvcRequestBuilders.post("/user")
.contentType(MediaType.APPLICATION_JSON_UTF8).content(content))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.name").value("tom"))
.andReturn().getResponse().getContentAsString();
//后台返回的日期格式也是长整形
System.out.println(tom);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 创建用户
*/
@Test
public void whenCreateSuccess() {
//前台传入的是长整形
Date date = new Date();
String content = "{\"name\":\"tom\",\"password\":\"\",\"birthday\":" + date.getTime() + "}";
try {
String tom = mockMvc.perform(MockMvcRequestBuilders.post("/user")
.contentType(MediaType.APPLICATION_JSON_UTF8).content(content))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$.name").value("tom"))
.andReturn().getResponse().getContentAsString();
//后台返回的日期格式也是长整形
System.out.println(tom);
} catch (Exception e) {
e.printStackTrace();
}
}
public void whenUpdateSuccess(){
//本地的时间加1年
Date date = new Date(LocalDateTime.now().plusYears(1).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
public void whenUpdateSuccess() {
//本地的时间加1年
Date date = new Date(LocalDateTime.now().plusYears(1).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
}
}
/**
* 测试上传文件
*/
@Test
public void whenUploadFileSuccess() {
try {
String result = mockMvc.perform(
MockMvcRequestBuilders
.fileUpload("/file")
.file(
new MockMultipartFile("file", "test.txt", ",multipart/form-data", "hello upload".getBytes("UTF-8"))
)
).andExpect(MockMvcResultMatchers.status().isOk())
.andReturn().getResponse().getContentAsString();
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
}
}
+1
View File
@@ -0,0 +1 @@
REDIS0006˙ÜłCđZÜňV
+8
View File
@@ -15,6 +15,14 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<modules>
<module>config-server</module>
<module>register-center1</module>
+54 -50
View File
@@ -1,62 +1,66 @@
<?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>
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>
<artifactId>performance-appraisal</artifactId>
<packaging>jar</packaging>
<artifactId>performance-appraisal</artifactId>
<packaging>jar</packaging>
<name>performance-appraisal</name>
<description>performance-appraisal</description>
<name>performance-appraisal</name>
<description>performance-appraisal</description>
<parent>
<groupId>com.micro.fast</groupId>
<artifactId>micro-fast</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<parent>
<groupId>com.micro.fast</groupId>
<artifactId>micro-fast</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>com.micro.fast</groupId>
<artifactId>boot-starter-ssm</artifactId>
<version>${micro.fast.version}</version>
</dependency>
<dependencies>
<dependency>
<groupId>com.micro.fast</groupId>
<artifactId>boot-starter-ssm</artifactId>
<version>${micro.fast.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--生成mybatis dao 层 sql mapper的插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
<!--</plugin>-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--生成mybatis dao 层 sql mapper的插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
<!--</plugin>-->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
<finalName>micro-fast-pa</finalName>
</build>
</plugins>
<finalName>micro-fast-pa</finalName>
</build>
</project>