启动应用输出后台地址和Swagger地址
This commit is contained in:
parent
6253e41658
commit
93ef7f7477
|
|
@ -4,6 +4,9 @@ import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动程序
|
* 启动程序
|
||||||
*
|
*
|
||||||
|
|
@ -12,7 +15,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||||
public class RuoYiApplication
|
public class RuoYiApplication
|
||||||
{
|
{
|
||||||
public static void main(String[] args)
|
public static void main(String[] args) throws UnknownHostException
|
||||||
{
|
{
|
||||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||||
SpringApplication.run(RuoYiApplication.class, args);
|
SpringApplication.run(RuoYiApplication.class, args);
|
||||||
|
|
@ -26,5 +29,12 @@ public class RuoYiApplication
|
||||||
" | | \\ `' /| `-' / \n" +
|
" | | \\ `' /| `-' / \n" +
|
||||||
" | | \\ / \\ / \n" +
|
" | | \\ / \\ / \n" +
|
||||||
" ''-' `'-' `-..-' ");
|
" ''-' `'-' `-..-' ");
|
||||||
|
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||||
|
String port = System.getProperty("server.port");
|
||||||
|
String path = System.getProperty("server.servlet.context-path");
|
||||||
|
String url = "http://" + ip + ":" + port + path;
|
||||||
|
String swaggerPrefix = path.endsWith("/") ? "" : "/";
|
||||||
|
System.out.println("后台管理地址:" + url);
|
||||||
|
System.out.println("Swagger地址(需登录):" + url + swaggerPrefix + "swagger-ui/index.html");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.ruoyi.framework.config;
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
|
|
||||||
|
|
@ -16,5 +18,21 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
@MapperScan("com.ruoyi.**.mapper")
|
@MapperScan("com.ruoyi.**.mapper")
|
||||||
public class ApplicationConfig
|
public class ApplicationConfig
|
||||||
{
|
{
|
||||||
|
/** 服务器的HTTP端口 */
|
||||||
|
@Value("${server.port}")
|
||||||
|
public String port;
|
||||||
|
|
||||||
|
/** 应用的访问路径 */
|
||||||
|
@Value("${server.servlet.context-path}")
|
||||||
|
public String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置系统配置
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public void setSystemProperty()
|
||||||
|
{
|
||||||
|
System.setProperty("server.port", port);
|
||||||
|
System.setProperty("server.servlet.context-path", path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue