JFianl3.3+jfianl-shiro-3.1.0报错,无法注入Route

在Config类里面配置shiro插件,代码如下:  

      Routes routes;

@Override

public void configInterceptor(Interceptors me) {

me.add(new ShiroInterceptor());

}

@Override

public void configRoute(Routes me) {

this.routes = me;

}

@Override

public void configPlugin(Plugins me) {

// 配置本地C3p0数据库连接池插件

DruidPlugin localDruidPlugin = SystemUtil.createDruidPlugin(Constant.DATASOURCE_LOCAL_MYSQL);

me.add(localDruidPlugin);

// 配置ActiveRecord插件

ActiveRecordPlugin arpLocal = new ActiveRecordPlugin("local", localDruidPlugin);

arpLocal.setShowSql(true);

me.add(arpLocal);

//加载Shiro插件

me.add(new ShiroPlugin(this.routes));

}

发现执行me.add(new ShiroPlugin(this.routes))这句的时候routes为null,routes没有被赋值,项目启动就报:

严重: Exception starting filter jfinal

java.lang.RuntimeException: Plugin start error: com.jfinal.ext.plugin.shiro.ShiroPlugin. 

null

at com.jfinal.core.Config.startPlugins(Config.java:116)

at com.jfinal.core.Config.configJFinal(Config.java:51)

at com.jfinal.core.JFinal.init(JFinal.java:63)

at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)

at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)

at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)

at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)

at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4700)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5340)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)

at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.NullPointerException

at com.jfinal.ext.plugin.shiro.ShiroPlugin.start(ShiroPlugin.java:106)

at com.jfinal.core.Config.startPlugins(Config.java:107)

... 15 more

是我哪里没配好吗?调了很久都不行

评论区

rock_ping

2018-01-24 15:49

@jFinal 波总能否指点下迷津

JFinal

2018-01-24 15:56

@rock_ping 用这个办法解决一下:http://www.jfinal.com/share/410

热门反馈

扫码入社