增加 springboot lombok

增加 springboot 热部署(热更替)
This commit is contained in:
YunaiV
2020-02-04 21:39:33 +08:00
parent 036a8610c9
commit 5cd2a6e766
18 changed files with 262 additions and 2 deletions

View File

@@ -15,8 +15,15 @@
## 打好基础
* [《芋道 Spring Boot 快速入门》](http://www.iocoder.cn/Spring-Boot/quick-start/?github)
* [《芋道 Spring Boot 自动配置原理》](http://www.iocoder.cn/Spring-Boot/autoconfigure/?github) 对应 [lab-47](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-47) 。
## 开发工具
* [《芋道 Spring Boot 热部署入门》](http://www.iocoder.cn/Spring-Boot/hot-swap/?github) 对应 [lab-48](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-48) 。
* [《芋道 Spring Boot 消除冗余代码 Lombok 入门》](http://www.iocoder.cn/Spring-Boot/Lombok/?github) 对应 [lab-49](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-49) 。
* 《芋道 Spring Boot 对象转换 MapStruct 入门》计划中...
## Web 开发
* [《芋道 Spring Boot SpringMVC 入门》](http://www.iocoder.cn/Spring-Boot/SpringMVC/?github) 对应 [lab-23](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-23) 。

View File

@@ -11,4 +11,9 @@
<artifactId>lab-09</artifactId>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
</project>

View File

@@ -13,7 +13,6 @@
<artifactId>lab-46-sentinel-demo-nacos</artifactId>
<dependencies>
<!-- 实现对 SpringMVC 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -0,0 +1,23 @@
<?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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-48-demo</artifactId>
<dependencies>
<!-- 实现对 SpringMVC 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,13 @@
package cn.iocoder.springboot.lab48.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}

View File

@@ -0,0 +1,16 @@
package cn.iocoder.springboot.lab48.demo.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/demo")
public class DemoController {
@GetMapping("/echo")
public String echo() {
return "echo";
}
}

19
lab-48/pom.xml Normal file
View File

@@ -0,0 +1,19 @@
<?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>labs-parent</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-48</artifactId>
<packaging>pom</packaging>
<modules>
<module>lab-48-demo</module>
</modules>
</project>

View File

@@ -0,0 +1,37 @@
<?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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-49-lombok-demo</artifactId>
<dependencies>
<!-- 引入 Spring Boot Starter 基础库 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- 引入 Lombok 依赖 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- 实现对 Test 的自动化配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,14 @@
package cn.iocoder.springboot.lab49.lombokdemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class LombokApplication {
public static void main(String[] args) {
// 启动 Spring Boot 应用
SpringApplication.run(LombokApplication.class, args);
}
}

View File

@@ -0,0 +1,16 @@
package cn.iocoder.springboot.lab49.lombokdemo.dataobject;
import lombok.Getter;
import lombok.Setter;
/**
* 用户 DO
*/
@Setter
@Getter
public class UserDO {
private String username;
private String password;
}

View File

@@ -0,0 +1,14 @@
package cn.iocoder.springboot.lab49.lombokdemo.dataobject;
import lombok.Data;
/**
* 用户 DO
*/
@Data
public class UserDO01 {
private String username;
private String password;
}

View File

@@ -0,0 +1,16 @@
package cn.iocoder.springboot.lab49.lombokdemo.service;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class UserService {
public static void staticMethod() {
log.info("静态方法示例");
}
public void normalMethod() {
log.info("普通方法示例");
}
}

View File

@@ -0,0 +1,27 @@
package cn.iocoder.springboot.lab49.lombokdemo.service;
import cn.iocoder.springboot.lab49.lombokdemo.dataobject.UserDO;
import com.sun.istack.internal.NotNull;
import lombok.NonNull;
import org.springframework.stereotype.Service;
@Service
public class UserService01 {
@NonNull
public void test01(UserDO userDO) {
System.out.println(userDO.getUsername());
System.out.println(userDO.getPassword());
}
public void test02(@NotNull String username, String password) {
}
public void test03() {
@NonNull String username = "";
String password = "";
}
}

View File

@@ -0,0 +1,17 @@
package cn.iocoder.springboot.lab49.lombokdemo.dataobject;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class UserDOTest {
@Test
public void demo01() {
UserDO user = new UserDO();
user.setUsername("username:1");
user.setPassword("password:1");
System.out.println(user);
}
}

View File

@@ -0,0 +1 @@
package cn.iocoder.springboot.lab49.lombokdemo;

View File

@@ -0,0 +1,16 @@
package cn.iocoder.springboot.lab49.lombokdemo.service;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class UserService01Test {
private UserService01 userService01 = new UserService01();
@Test
public void test02() {
userService01.test02(null, null);
}
}

19
lab-49/pom.xml Normal file
View File

@@ -0,0 +1,19 @@
<?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>labs-parent</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-49</artifactId>
<packaging>pom</packaging>
<modules>
<module>lab-49-lombok-demo</module>
</modules>
</project>

View File

@@ -56,7 +56,8 @@
<module>lab-45</module>
<module>lab-46</module>
<module>lab-47</module>
<module>lab-48</module>
<module>lab-49</module>
</modules>
</project>