zhangxu
2022-07-20 6d74163dc2d9675d0af367c86a0c9c70cbd18cd3
提交 | 用户 | age
38cba9 1 package com.hx.phip;
707c81 2
C 3 import com.hx.util.AesUtil;
38cba9 4 import com.hx.phip.config.UniqueNameGenerator;
707c81 5 import org.mybatis.spring.annotation.MapperScan;
C 6 import org.springframework.boot.CommandLineRunner;
7 import org.springframework.boot.SpringApplication;
8 import org.springframework.boot.autoconfigure.SpringBootApplication;
9 import org.springframework.boot.builder.SpringApplicationBuilder;
10 import org.springframework.boot.web.servlet.ServletComponentScan;
11 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
6d7416 12 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
Z 13 import org.springframework.cloud.openfeign.EnableFeignClients;
707c81 14 import org.springframework.context.annotation.ComponentScan;
C 15
16 @SpringBootApplication
d00a65 17 @MapperScan({"com.gitee.sunchenbin.mybatis.actable.dao.*","com.hx.phip.dao.*"})
bddc3f 18 @ComponentScan(basePackages = {"com.gitee.sunchenbin.mybatis.actable.manager.*","com.hx.phip.*","com.hx.common.service.impl","com.hx.redis","com.hx.mybatis.aes.springbean"},nameGenerator = UniqueNameGenerator.class)
707c81 19 @ServletComponentScan
38cba9 20 //@EnableScheduling
6d7416 21 @EnableDiscoveryClient
Z 22 @EnableFeignClients
d00a65 23 public class PhiPlatformUserApplication extends SpringBootServletInitializer implements CommandLineRunner {
707c81 24
C 25     public static void main(String[] args) {
26
27         //获取项目部署路径
d00a65 28         String jarWholePath = PhiPlatformUserApplication.class.getProtectionDomain().getCodeSource().getLocation().getFile();
707c81 29         /*try {
C 30             jarWholePath = java.net.URLDecoder.decode(jarWholePath, "UTF-8");
31             System.setProperty("address.jarWholePath", jarWholePath);
32         } catch (UnsupportedEncodingException e) { System.out.println(e.toString()); }
33         String jarPath = new File(jarWholePath).getParentFile().getAbsolutePath();
34         System.setProperty("address.jarPath", jarPath);*/
35
36         if(System.getProperty("os.name").contains("dows")) {
37             jarWholePath = jarWholePath.substring(1,jarWholePath.length());
38         }
39         if(jarWholePath.contains("jar")) {
40             jarWholePath = jarWholePath.substring(0,jarWholePath.lastIndexOf("."));
41             jarWholePath = jarWholePath.substring(0,jarWholePath.lastIndexOf("/"));
42         }
43         jarWholePath = jarWholePath.replace("target/classes/", "").replace("file:","");
44         System.setProperty("address.jarPath",jarWholePath );
45
46         //设置配置文件项加密密钥(放在这里使加密密钥和密文分开)
47         System.setProperty("jasypt.encryptor.password", AesUtil.SECRET);
d00a65 48         SpringApplication.run(PhiPlatformUserApplication.class, args);
707c81 49     }
C 50
51     @Override
52     protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
d00a65 53         return builder.sources(PhiPlatformUserApplication.class);
707c81 54     }
C 55
56     @Override
57     public void run(String... args) {
58         System.out.println("SpringBoot is Running...");
59     }
60 }