我的程序使用java -jar target/demo.jar可以正常访问webapp里面的资源,而使用java -jar demo.jar则报错找不到文件如图:
这个是我demo打包好的程序
这个是我undertow.txt的配置
我的democonfig的配置:
package com.example.config;
import com.example.controller.HomeController;
import com.example.controller.Scheduler;
import com.example.model.Check;
import com.example.model.Dict;
import com.example.model.Group;
import com.example.model.GroupPerson;
import com.example.model.Person;
import com.example.model.Plan;
import com.example.model.PlanOrder;
import com.example.routers.FrontRoutes;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;
import com.jfinal.template.Engine;
public class DemoConfig extends JFinalConfig {
@Override
public void configConstant(Constants me) {
loadPropertyFile("config.properties");
me.setDevMode(true);
// 配置 404、500 页面
me.setViewType(ViewType.FREE_MARKER);
me.setError404View("/WEB-INF/views/error/404.html");
me.setError500View("/WEB-INF/views/error/500.html");
me.setError401View("/WEB-INF/views/error/401.html");
me.setError403View("/WEB-INF/views/error/403.html");
// 开启解析 json 请求,5.0.0 版本新增功能
me.setResolveJsonRequest(true);
}
@Override
public void configEngine(Engine me) {
me.setDevMode(true);
me.setBaseTemplatePath("/WEB-INF/views");
}
@Override
public void configHandler(Handlers me) {
}
@Override
public void configInterceptor(Interceptors me) {
}
@Override
public void configPlugin(Plugins me) {
String jdbcUrl = getProperty("jdbcUrl");
String user = getProperty("user");
String password = getProperty("password");
String driverClass = getProperty("driverClass");
C3p0Plugin c3p0Plugin = new C3p0Plugin(jdbcUrl, user, password, driverClass);
c3p0Plugin.setInitialPoolSize(getPropertyToInt("initialPoolSize", 5));
c3p0Plugin.setMinPoolSize(getPropertyToInt("minPoolSize", 5));
c3p0Plugin.setMaxPoolSize(getPropertyToInt("maxPoolSize", 20));
c3p0Plugin.setMaxIdleTime(getPropertyToInt("maxIdleTime", 300));
me.add(c3p0Plugin);
ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
me.add(arp);
arp.addMapping("gc_schedule_person", "pid", Person.class); // 映射表gc_schedule_person到
// Person模型,指定主键为pid,不指定主键将会默认是id
// 词典翻译
arp.addMapping("gc_common_dict", Dict.class);
// 人员分组
arp.addMapping("gc_schedule_group", "gid", Group.class);
// 班次设置
arp.addMapping("gc_schedule_plan", "pid", Plan.class);
arp.addMapping("gc_schedule_planorder", PlanOrder.class);
// 排班管理
arp.addMapping("gc_schedule_group_person_v", "gid", GroupPerson.class);
arp.addMapping("gc_schedule_scheduler", Scheduler.class);
// 考勤统计
arp.addMapping("gc_schedule_check_statistics_v", Check.class);
}
@Override
public void configRoute(Routes me) {
me.add(new FrontRoutes());
}
}