SpringBoot2启动执行特定方法 springboot 获取项目绝对路径


springboot 获取项目绝对路径

ClassUtils.getDefaultClassLoader().getResource("").getPath();             


添加类 

package com.ps.uzkefu.apps.ctilink.config;

/**
 * Author:ZhuShangJin
 * Date:2018/6/26
 */
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * Created by pangkunkun on 2017/9/3.
 */
@Component
public class EventApplicationRunner implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments var1) throws Exception{
        //启动后执行
        System.out.println("MyApplicationRunner class will be execute when the project was started!");
    }

}



ClassUtils.getDefaultClassLoader().getResource("").getPath();             

猜你喜欢

转载自blog.csdn.net/zsj777/article/details/80816092