From 168785a8cce0963ebe4cfa911f6c98761227d051 Mon Sep 17 00:00:00 2001 From: ck <851316342@qq.com> Date: Thu, 8 Apr 2021 18:58:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=87=AA=E5=8A=A8=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=AE=8C=E6=88=90=E6=89=93=E5=BC=80IE=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jingcheng/cms/conf/MyCommandRunner.java | 33 +++++++++++++++++++ src/main/resources/application-production.yml | 5 ++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/jingcheng/cms/conf/MyCommandRunner.java 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