linzhijie
2021-03-11 c33914ba0a98c823c4b4d7da21cdd476906c9924
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.ots;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import org.jasypt.encryption.StringEncryptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
 
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableEncryptableProperties
public class OtsApplication implements CommandLineRunner {
 
    private static final Logger l = LoggerFactory.getLogger(OtsApplication.class);
 
    @Autowired
    private StringEncryptor stringEncryptor;
 
    @Autowired
    private ApplicationContext applicationContext;
 
    public static void main(String[] args) {
        
        SpringApplication.run(OtsApplication.class, args);
        StringBuilder builder = new StringBuilder();
        builder.append("********************************************************************\n");
        builder.append("**     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^      **\n");
        builder.append("**                  TAI Online Testing System(OTS)              **\n");
        builder.append("**                            启动成功                            **\n");
        builder.append("**     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^      **\n");
        builder.append("********************************************************************\n");
        System.out.println(builder.toString());
    }
 
    @Override
    public void run(String... args) throws Exception {
        Environment environment = applicationContext.getEnvironment();
        l.info(stringEncryptor.encrypt(environment.getProperty("password")));
    }
}