2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.landtool.lanbase;
 
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Properties;
 
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.core.convert.converter.Converter;
 
import com.github.pagehelper.PageHelper;
 
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
import org.springframework.scheduling.annotation.EnableScheduling;
 
@SpringBootApplication
@EnableScheduling
public class LanbaseApplication extends SpringBootServletInitializer {
 
    
    
    /**
     * 启动程序方法
     */
    public static void main(String[] args) {
        //showEnvironment();
        SpringApplication.run(LanbaseApplication.class, args);
    }
 
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(LanbaseApplication.class);
    }
    @Bean
    public Converter<String, Timestamp> addNewConvert() {
        return new Converter<String, Timestamp>() {
            @Override
            public Timestamp convert(String source) {
                if(source.equals("")){
                    return null;
                }else {
                    DateFormat dateFormat;
                    dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);//设定格式
                    //dateFormat = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss", Locale.ENGLISH);
                    dateFormat.setLenient(false);
                    Date timeDate = null;//util类型
                    try {
                        timeDate = dateFormat.parse(source);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    java.sql.Timestamp dateTime = new java.sql.Timestamp(timeDate.getTime());//Timestamp类型,timeDate.getTime()返回一个long型
                    return dateTime;
                }
 
            }
        };
    }
    @Bean
    public PageHelper pageHelper(){
        PageHelper pageHelper = new PageHelper();
        Properties properties = new Properties();
        properties.setProperty("offsetAsPageNum","true");
        properties.setProperty("rowBoundsWithCount","true");
        properties.setProperty("reasonable","true");
        properties.setProperty("dialect","PostgreSQL");
        pageHelper.setProperties(properties);
        return pageHelper;
    }
 
//    <!--shiro整合thymeleaf-->
    @Bean
    public ShiroDialect shiroDialect() {
        return new ShiroDialect();
    }
 
    private static void showEnvironment(){
        System.out.println("java版本号:" + System.getProperty("java.version")); 
        System.out.println("Java提供商名称:" + System.getProperty("java.vendor")); 
//        System.out.println("Java提供商网站:" + System.getProperty("java.vendor.url")); 
        System.out.println("jre主目录:" + System.getProperty("java.home")); 
//        System.out.println("Java虚拟机规范版本号:" + System.getProperty("java.vm.specification.version")); 
//        System.out.println("Java虚拟机规范提供商:" + System.getProperty("java.vm.specification.vendor")); 
//        System.out.println("Java虚拟机规范名称:" + System.getProperty("java.vm.specification.name")); 
        System.out.println("Java虚拟机版本号:" + System.getProperty("java.vm.version"));  
        System.out.println("Java虚拟机提供商:" + System.getProperty("java.vm.vendor"));
        System.out.println("Java虚拟机名称:" + System.getProperty("java.vm.name")); 
//        System.out.println("Java规范版本号:" + System.getProperty("java.specification.version")); 
//        System.out.println("Java规范提供商:" + System.getProperty("java.specification.vendor"));  
//        System.out.println("Java规范名称:" + System.getProperty("java.specification.name"));
        System.out.println("Java类版本号:" + System.getProperty("java.class.version"));  
        System.out.println("Java类路径:" + System.getProperty("java.class.path")); 
        System.out.println("Java lib路径:" + System.getProperty("java.library.path")); 
        System.out.println("Java输入输出临时路径:" + System.getProperty("java.io.tmpdir")); 
        System.out.println("Java编译器:" + System.getProperty("java.compiler")); 
        System.out.println("Java执行路径:" + System.getProperty("java.ext.dirs")); 
        System.out.println("操作系统名称:" + System.getProperty("os.name")); 
        System.out.println("操作系统的架构:" + System.getProperty("os.arch")); 
        System.out.println("操作系统版本号:" + System.getProperty("os.version"));
        System.out.println("文件分隔符:" + System.getProperty("file.separator")); 
        System.out.println("路径分隔符:" + System.getProperty("path.separator"));   
        System.out.println("直线分隔符:" + System.getProperty("line.separator"));  
        System.out.println("操作系统用户名:" + System.getProperty("user.name"));  
        System.out.println("操作系统用户的主目录:" + System.getProperty("user.home")); 
        System.out.println("当前程序所在目录:" + System.getProperty("user.dir"));  
    }
}