leomon
2025-07-09 48b6f19e19502b2f6469bab3e6a266d88a8e9c8b
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
 
package com.oying;
 
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import com.oying.annotation.rest.AnonymousGetMapping;
import com.oying.utils.SpringBeanHolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * @author Z
 * @date 2018/11/15 9:20:19
 */
@Slf4j
@RestController
@Api(hidden = true)
@SpringBootApplication
@EnableTransactionManagement
public class AppRun {
 
    public static void main(String[] args) {
        SpringApplication springApplication = new SpringApplication(AppRun.class);
        // 监控应用的PID,启动时可指定PID路径:--spring.pid.file=/home/oying/app.pid
        // 或者在 application.yml 添加文件路径,方便 kill,kill `cat /home/oying/app.pid`
        springApplication.addListeners(new ApplicationPidFileWriter());
        springApplication.run(args);
        log.info("---------------------------------------------");
        log.info("Local: {}", "http://localhost:8000");
        log.info("Swagger: {}", "http://localhost:8000/doc.html");
        log.info("---------------------------------------------");
    }
 
    @Bean
    public SpringBeanHolder springContextHolder() {
        return new SpringBeanHolder();
    }
 
    /**
     * 访问首页提示
     * @return /
     */
    @AnonymousGetMapping("/")
    public String index() {
        return "Backend service started successfully";
    }
}