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 addNewConvert() { return new Converter() { @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; } // @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")); } }