diff --git a/src/main/java/com/jingcheng/cms/conf/MyCommandRunner.java b/src/main/java/com/jingcheng/cms/conf/MyCommandRunner.java new file mode 100644 index 0000000..46903db --- /dev/null +++ b/src/main/java/com/jingcheng/cms/conf/MyCommandRunner.java @@ -0,0 +1,33 @@ +package com.jingcheng.cms.conf; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; + + +@Component +public class MyCommandRunner implements CommandLineRunner { + private static Logger logger = LoggerFactory.getLogger(MyCommandRunner.class); + + @Value("${cmd.loginurl}") + private String loginUrl; + + @Value("${cmd.command}") + private String command; + + + @Override + public void run(String... args) throws Exception { + String cmd = command +" "+ loginUrl; + Runtime run = Runtime.getRuntime(); + try{ + run.exec(cmd); + logger.debug("启动浏览器打开项目成功"); + }catch (Exception e){ + e.printStackTrace(); + logger.error(e.getMessage()); + } + } +} diff --git a/src/main/resources/application-production.yml b/src/main/resources/application-production.yml index e24b785..7aa5d2b 100644 --- a/src/main/resources/application-production.yml +++ b/src/main/resources/application-production.yml @@ -77,4 +77,7 @@ oss: accessKey: bE00QP1WdBlxk7vFGdIA3rxZikP7HY maxFileSize: 102400KB maxRequestSize: 1024000KB - filedir: cases/ \ No newline at end of file + filedir: cases/ +cmd: + loginurl: http://localhost:8888 + command: cmd /c start iexplore \ No newline at end of file