forked from dyc87112/SpringBoot-Learning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 21 additions & 3 deletions
24
2.x/chapter1-5/src/main/java/com/didispace/chapter15/Chapter15Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
package com.didispace.chapter15; | ||
|
||
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@SpringBootApplication | ||
@EnableEncryptableProperties | ||
public class Chapter15Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Chapter15Application.class, args); | ||
} | ||
public static void main(String[] args) { | ||
SpringApplication.run(Chapter15Application.class, args); | ||
} | ||
|
||
@RestController | ||
static class HelloController { | ||
|
||
@Autowired | ||
private JasyptExample jasyptExample; | ||
|
||
@GetMapping("/hello") | ||
public String hello() { | ||
return "Hello World, " + jasyptExample.getFrom2(); | ||
} | ||
|
||
} | ||
|
||
} |
14 changes: 0 additions & 14 deletions
14
2.x/chapter1-5/src/main/java/com/didispace/chapter15/HelloController.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
2.x/chapter1-5/src/main/java/com/didispace/chapter15/JasyptExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.didispace.chapter15; | ||
|
||
import lombok.Data; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Data | ||
@Component | ||
public class JasyptExample { | ||
|
||
@Value("${com.didispace.from1:}") | ||
private String from1; | ||
@Value("${com.didispace.from2:}") | ||
private String from2; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
|
||
com.didispace.from=didi | ||
com.didispace.from1=didi | ||
com.didispace.from2=ENC(1I1oWHryzOJt+Gm81xnGnOUbBUpEBEFYES/NprA/q6ec3jBkU1xlBZWsHCaj71ds) | ||
|
||
jasypt.encryptor.password=didispace | ||
|
||
#[INFO] Encryptor config not found for property jasypt.encryptor.salt-generator-classname, using default value: org.jasypt.salt.RandomSaltGenerator | ||
#[INFO] Encryptor config not found for property jasypt.encryptor.iv-generator-classname, using default value: org.jasypt.iv.RandomIvGenerator | ||
|
||
# mvn jasypt:encrypt -Djasypt.encryptor.password=didispace | ||
# mvn jasypt:decrypt -Djasypt.encryptor.password=didispace |
21 changes: 21 additions & 0 deletions
21
2.x/chapter1-5/src/test/java/com/didispace/chapter15/PropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.didispace.chapter15; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@Slf4j | ||
@SpringBootTest | ||
public class PropertiesTest { | ||
|
||
@Autowired | ||
private JasyptExample jasyptExample; | ||
|
||
@Test | ||
public void test() { | ||
log.info("from1 : {}", jasyptExample.getFrom1()); | ||
log.info("from2 : {}", jasyptExample.getFrom2()); | ||
} | ||
|
||
} |