You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.2 KiB
87 lines
2.2 KiB
package com.dsideal.gw;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
import com.dsideal.gw.Controller.IndexController;
|
|
import com.jfinal.config.*;
|
|
import com.jfinal.kit.PropKit;
|
|
import com.jfinal.plugin.redis.RedisPlugin;
|
|
import com.jfinal.server.undertow.UndertowServer;
|
|
import com.jfinal.template.Engine;
|
|
|
|
import java.io.File;
|
|
|
|
public class GwApplication extends JFinalConfig {
|
|
|
|
public static String getEnvPrefix() {
|
|
String myEnvVar = System.getenv("WORKING_ENV");
|
|
return myEnvVar == null ? "dev" : "pro";
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
System.out.println("当前环境: " + getEnvPrefix());
|
|
String configFile = "undertow_{?}.properties".replace("{?}", getEnvPrefix());
|
|
UndertowServer.create(GwApplication.class, configFile).start();
|
|
}
|
|
|
|
/**
|
|
* 配置常量
|
|
*/
|
|
@Override
|
|
public void configConstant(Constants me) {
|
|
//加载配置文件
|
|
String configFile = "application_{?}.properties".replace("{?}", getEnvPrefix());
|
|
PropKit.use(configFile);
|
|
}
|
|
|
|
/**
|
|
* 配置路由
|
|
*/
|
|
@Override
|
|
public void configRoute(Routes me) {
|
|
//默认页面
|
|
me.add("/dsBase", IndexController.class);
|
|
|
|
}
|
|
|
|
@Override
|
|
public void configEngine(Engine engine) {
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
public void configPlugin(Plugins me) {
|
|
// 用于缓存模块的redis服务
|
|
//RedisPlugin redis = new RedisPlugin("Redis", PropKit.get("redis_ip"), PropKit.getInt("redis_port"), 10 * 1000);
|
|
//启动redis组件
|
|
//me.add(redis);
|
|
}
|
|
|
|
/**
|
|
* 配置全局拦截器
|
|
*/
|
|
@Override
|
|
public void configInterceptor(Interceptors me) {
|
|
|
|
}
|
|
|
|
/**
|
|
* 配置处理器
|
|
*/
|
|
@Override
|
|
public void configHandler(Handlers me) {
|
|
}
|
|
|
|
/**
|
|
* 在jfinal启动完成后马上执行
|
|
*/
|
|
@Override
|
|
public void onStart() {
|
|
//打印 启动Logo
|
|
String path = GwApplication.class.getClassLoader().getResource("logo.txt").getPath();
|
|
File file = new File(path);
|
|
System.out.println(FileUtil.readUtf8String(file));
|
|
}
|
|
}
|