jbolt新手搭建出现异常,大佬求助

package cn.jbolt.api;

import java.util.List;

import com.jfinal.aop.Inject;

import com.jfinal.core.Controller;

import cn.jbolt.common.service.CouponGoodsService;

public class CouponController extends Controller {

/**

* 首页Action

*/

@Inject 

CouponGoodsService service;

public void index() {

try {

setAttr("list", service.paginate(1, 10));

}catch(Exception e ) {

renderText(e.getMessage());

}

        //render("/WEB-INF/view/index/list.html");

}

}

service层

package cn.jbolt.common.service;

import java.util.List;

import com.jfinal.plugin.activerecord.Page;

import cn.jbolt.common.model.CouponGoods;


public class CouponGoodsService {

    /**

     * 所有的 dao 对象也放在 Service 中

     */

    private static final CouponGoods dao = new CouponGoods().dao();

    public Page<CouponGoods> paginate(int pageNumber, int pageSize) {

        return dao.paginate(pageNumber, pageSize, "select *", "from coupon_goods order by id asc");

    }

    

    public CouponGoods findById(int id) {

        return dao.findById(id);

    }

    

    public void deleteById(int id) {

        dao.deleteById(id);

        

    }

    public List<CouponGoods> find() {

        

        return dao.find("select * from coupon_goods order by id asc");

    }

    

}

model层

package cn.jbolt.common.model;

import cn.jbolt.common.model.base.BaseCouponGoods;


/**

 * Generated by JFinal.

 */

@SuppressWarnings("serial")

public class CouponGoods extends BaseCouponGoods<CouponGoods> {

public static final CouponGoods dao = new CouponGoods().dao();

}


用maven jetty run出现的异常


[ERROR]-[Thread: qtp665512315-24]-[com.jfinal.core.JFinalFilter.doFilter()]: /api/coupon/index

java.lang.IllegalStateException: WRITER

at org.eclipse.jetty.server.Response.getOutputStream(Response.java:667)

at com.jfinal.render.ErrorRender.render(ErrorRender.java:58)

at com.jfinal.core.ActionHandler.handle(ActionHandler.java:125)

at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1476)

at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)

at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)

at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)

at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)

at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)

at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)

at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)

at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)

at org.eclipse.jetty.server.Server.handle(Server.java:370)

at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)

at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:971)

at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1033)

at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)

at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)

at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)

at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:696)

at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:53)

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)

at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)

at java.lang.Thread.run(Unknown Source)


评论区

山东小木

2019-07-03 15:30

JFinal搭建开发环境 在JFinal文档里有,https://www.jfinal.com/doc/1-6 运行可以不用mvn的

除了传统一步步集成搭建(太繁琐)的方式,如果在Eclipse下搭建开发环境 推荐使用JBolt插件一键生成开发环境。http://www.jfinal.com/share/1678

ZJW6817239

2019-07-03 16:06

@JFinal 已经解决了,忘了添加arp.addMapping("coupongoods", "id", CouponGoods.class);这句,谢谢大佬

ZJW6817239

2019-07-03 16:06

@山东小木 已经解决了,忘了添加arp.addMapping("coupongoods", "id", CouponGoods.class);这句,谢谢大佬

ZJW6817239

2019-07-03 16:07

我是看图文搭建,自己也是刚开始玩jfinal,有点生疏,jbolt用起来真心不错,赞

ZJW6817239

2019-07-03 16:15

已经解决了,谢谢大佬支持,我也是按照jbolt图文教程来的,有个_MappingKit.java没有生成出来,造成我调试一直报错,我自己新建了这个文件,并且打开注释_MappingKit.mapping(arp);然后再_MappingKit.java文件中添加arp.addMapping("coupongoods", "id", CouponGoods.class)这句,重新再运行就行了,我用的是企业版eclispse Version: 2019-03 (4.11.0)。

JFinal

2019-07-03 17:26

@ZJW6817239 不建议使用 arp.addMapping(...)

而是用生成器自动生成 _MappingKit, 这个里头会自动化进行映射

ZJW6817239

2019-07-03 17:37

@JFinal 好的,十分感谢大佬

热门反馈

扫码入社