Springboot development practical chapter - configuration advanced - common UOM application, bean attribute validation framework, hexadecimal data conversion rules

Ghost Knight 2022-05-22 13:09:32 阅读数:959

springbootdevelopmentpracticalchapterconfiguration

Common UOM application

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-PoNpyno0-1653110092345)(springboot.assets/image-20220521103150490.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-vQ8hKre6-1653110092347)(springboot.assets/image-20220521103234673.png)]

Summary

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-YuYMAI36-1653110092348)(springboot.assets/image-20220521103330098.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-HCxLFk1h-1653110092349)(springboot.assets/image-20220521103609819.png)]

Bean Attribute verification framework

Case simulation

<!-- 1. Import JSR303 standard -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-J96OuONU-1653110092350)(springboot.assets/image-20220521105951662.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-sYTFndZJ-1653110092351)(springboot.assets/image-20220521111433695.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-oudjFI3q-1653110092352)(springboot.assets/image-20220521111510224.png)]

test run

Check qualified

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-q28zBw3d-1653110092354)(springboot.assets/image-20220521114551575.png)]

Over the maximum

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Zfohsl1Y-1653110092355)(springboot.assets/image-20220521114634996.png)]

Summary

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-bDH0yk1v-1653110092356)(springboot.assets/image-20220521114726111.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-KBO0dsUz-1653110092357)(springboot.assets/image-20220521114735997.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-u8SPC8RI-1653110092357)(springboot.assets/image-20220521114743559.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-eC2krsAb-1653110092358)(springboot.assets/image-20220521114752560.png)]

Binary data conversion rules

Case simulation

To write Springboot13ConfigurationApplicationTests.java

package com.taotao;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class Springboot13ConfigurationApplicationTests {

@Value("${dataSource.password}")
private String password;
@Test
void contextLoads() {

System.out.println(password);
}
}

To write application.yml

servers:
ipAddress: 192.168.0.1
port: 2222
timeout: -1
serverTimeOut: 3
dataSource:
driverClassName: com.mysql.jdbc.Driver456
password: 0127

test run

Output 8 It's binary 87, the reason being that 0 At the beginning 127

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Aag8qWUC-1653110092358)(springboot.assets/image-20220521125503596.png)]

So let's change password, Wrap... In double quotation marks

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-PiRBwcST-1653110092359)(springboot.assets/image-20220521131301344.png)]

Summary

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-lnpU5ndn-1653110092360)(springboot.assets/image-20220521124744831.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-iz12W7eC-1653110092360)(springboot.assets/image-20220521131349050.png)]

[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-Jfr8ijqX-1653110092361)(springboot.assets/image-20220521131404730.png)]

copyright:author[Ghost Knight],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/142/202205211907229754.html