2.2 创建maven目录结构,以及pom.xml文件
<parent >
<groupId >org.springframework.boot</groupId >
<artifactId >spring-boot-starter-parent</artifactId >
<version >2.0.5.RELEASE</version >
<relativePath />
</parent >
2.4 pom.xml文件中加入springboot-starter依赖
<dependencies >
<!-- web启动器 -->
<dependency >
<groupId >org.springframework.boot</groupId >
<artifactId >spring-boot-starter-web</artifactId >
</dependency >
<!-- lombok支持 -->
<dependency >
<groupId >org.projectlombok</groupId >
<artifactId >lombok</artifactId >
</dependency >
<!-- 配置文件加密 -->
<dependency >
<groupId >com.github.ulisesbocchio</groupId >
<artifactId >jasypt-spring-boot-starter</artifactId >
<version >2.1.1</version >
</dependency >
<dependency >
<groupId >org.springframework.boot</groupId >
<artifactId >spring-boot-starter-test</artifactId >
<scope >test</scope >
</dependency >
</dependencies >
2.5 pom.xml文件中加入maven-springboot打包插件
<build >
<plugins >
<plugin >
<groupId >org.springframework.boot</groupId >
<artifactId >spring-boot-maven-plugin</artifactId >
</plugin >
</plugins >
</build >
import org .springframework .boot .SpringApplication ;
import org .springframework .boot .autoconfigure .SpringBootApplication ;
@ SpringBootApplication
public class Application {
public static void main (String [] args ) {
SpringApplication .run (Application .class , args );
}
}
import org .springframework .beans .factory .annotation .Value ;
import org .springframework .web .bind .annotation .RequestMapping ;
import org .springframework .web .bind .annotation .RestController ;
@ RestController
public class TestController {
@ Value ("${com.name}" )
private String name ;
@ RequestMapping ("/get" )
public String get () {
return name ;
}
}
# 用来加密的salt值
jasypt.encryptor.password =5217
# 加密的算法
jasypt.encryptor.iv-generator-classname =org.jasypt.salt.RandomIVGenerator
com.name =ENC(kwYxvK1ssjcDMCMqMdRhvQ ==)