`
陆地小神仙
  • 浏览: 8747 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

JFast应用系列之(1) -- Java Restful 服务端 项目搭建

 
阅读更多

   jfast 是一款Java语言的Resuful服务端框架。

   优点:

        简单,学习成本低

        开发速度不是一般快

   下面介绍下jfast 项目搭建过程。

   1. 下载jfast相关jar包:

        jfast-framework-api-0.0.1-SNAPSHOT.jar

        jfast-framework-core-0.0.1-SNAPSHOT.jar

        jfast-framework-dao-0.0.1-SNAPSHOT.jar

        jfast-framework-job-0.0.1-SNAPSHOT.jar 

        jfast-framework-log-0.0.1-SNAPSHOT.jar

        jfast-framework-upload-0.0.1-SNAPSHOT.jar

        asm-4.2.jar

        cglib-3.1.jar

        ezmorph-1.0.6.jar

        javassist-3.11.0.GA.jar

        mysql-connector-java-5.1.34.jar

    2.下载jfast代码生成插件(eclipse)

        JFast代码自动生成_Eclipse插件.jar

    3.将下载好的代码生成插件,复制到eclipse目录中的plugins目录下

    4.打开eclipse新建一个Web Project,导入上面下载的jar包,然后创建你需要的各个包

    
       
 

    5.选择菜单 JFast -- Auto Generate 生成代码:

       

      
  

       配置好连接参数,点击连接:

       
       
 

       其中表名对应的类名可以手动修改,这里使用默认的就行了,点击Next> 进入路径选择页面:

 
       
       配置好对应类存放路径点击Finish:

 
       

      这样项目文件和jfast必须的配置文件都自动生成好了

    
      6.配置web.xml:

     

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
	<filter>
		<filter-name>jfast</filter-name>
		<filter-class>cn.jfast.framework.web.filter.RestfulFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>jfast</filter-name>
		<url-pattern>/*</url-pattern>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>FORWARD</dispatcher>
	</filter-mapping>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
	</welcome-file-list>
</web-app>

    

    好了,jfast项目已经创建完毕,启动看看:

    

八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] java.version ---- 1.7.0_51
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] java.home ---- D:\java\jdk1.7.0_51\jre
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] java.class.version ---- 51.0
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] os.name ---- Windows 8
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] os.arch ---- x86
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] os.version ---- 1.7.0_51
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] user.name ---- jfast
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] user.home ---- C:\Users\jfast
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] user.dir---- D:\tomcat\apache-tomcat-6.0.44\bin
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] host.ip ---- 172.16.28.72
八月 20, 2015 10:30:00 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] host.name ---- zhuhy
八月 20, 2015 10:30:00 上午 com.mchange.v2.log.MLog <clinit>
信息: MLog clients using java 1.4+ standard logging.
八月 20, 2015 10:30:00 上午 com.mchange.v2.c3p0.C3P0Registry banner
信息: Initializing c3p0-0.9.0 [built 11-July-2005 00:43:29 -0400; debug? true; trace: 10]
八月 20, 2015 10:30:00 上午 com.mchange.v2.c3p0.PoolBackedDataSource getPoolManager
信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource@1072f13[ acquireIncrement -> 4, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1072f13, idleConnectionTestPeriod -> -1, initialPoolSize -> 10, jdbcUrl -> jdbc:mysql://localhost:3306/mall?characterEncoding=utf8&generateSimpleParameterMetadata=true, loginTimeout -> 0, maxIdleTime -> 20, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ]
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load database information---- success
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] database name ---- MySQL
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] database version ---- 5.6.25-log
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] database driver ---- mysql-connector-java-5.1.34 ( Revision: jess.balint@oracle.com-20141014163213-wqbwpf1ok2kvo1om )
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: sellerDao | target : SellerDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: msgDao | target : MsgDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: storeDao | target : StoreDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: commentDao | target : CommentDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: menuDao | target : MenuDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: orderdetailDao | target : OrderdetailDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: orderDao | target : OrderDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: contactDao | target : ContactDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: clubberDao | target : ClubberDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: wareDao | target : WareDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load dao ---- alias: templateDao | target : TemplateDaoImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : menuService | target : MenuServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : sellerService | target : SellerServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : commentService | target : CommentServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : contactService | target : ContactServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : orderService | target : OrderServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : orderdetailService | target : OrderdetailServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : msgService | target : MsgServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : storeService | target : StoreServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : wareService | target : WareServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : templateService | target : TemplateServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load resource ---- alias : clubberService | target : ClubberServiceImpl | description: 
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/templates/$post$ | target: TemplateController.addTemplate() | description: 添加新Template信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/templates/:templateid/$get$ | target: TemplateController.getTemplate() | description: 查询指定主键的Template信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/templates/:templateid/$delete$ | target: TemplateController.deleteTemplate() | description: 更新指定主键的Template信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/templates/:templateid/$put$ | target: TemplateController.updateTemplate() | description: 更新指定主键的Template信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/msgs/:msgid/$put$ | target: MsgController.updateMsg() | description: 更新指定主键的Msg信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/msgs/$post$ | target: MsgController.addMsg() | description: 添加新Msg信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/msgs/:msgid/$delete$ | target: MsgController.deleteMsg() | description: 更新指定主键的Msg信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/msgs/:msgid/$get$ | target: MsgController.getMsg() | description: 查询指定主键的Msg信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/menus/:menuid/$put$ | target: MenuController.updateMenu() | description: 更新指定主键的Menu信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/menus/:menuid/$delete$ | target: MenuController.deleteMenu() | description: 更新指定主键的Menu信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/menus/:menuid/$get$ | target: MenuController.getMenu() | description: 查询指定主键的Menu信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/menus/$post$ | target: MenuController.addMenu() | description: 添加新Menu信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/orders/:orderid/$put$ | target: OrderController.updateOrder() | description: 更新指定主键的Order信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/orders/:orderid/$get$ | target: OrderController.getOrder() | description: 查询指定主键的Order信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/orders/:orderid/$delete$ | target: OrderController.deleteOrder() | description: 更新指定主键的Order信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/orders/$post$ | target: OrderController.addOrder() | description: 添加新Order信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/wares/:wareid/$get$ | target: WareController.getWare() | description: 查询指定主键的Ware信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/wares/$post$ | target: WareController.addWare() | description: 添加新Ware信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/wares/:wareid/$put$ | target: WareController.updateWare() | description: 更新指定主键的Ware信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/wares/:wareid/$delete$ | target: WareController.deleteWare() | description: 更新指定主键的Ware信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/sellers/:sellerid/$get$ | target: SellerController.getSeller() | description: 查询指定主键的Seller信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/sellers/:sellerid/$delete$ | target: SellerController.deleteSeller() | description: 更新指定主键的Seller信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/sellers/:sellerid/$put$ | target: SellerController.updateSeller() | description: 更新指定主键的Seller信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/sellers/$post$ | target: SellerController.addSeller() | description: 添加新Seller信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/comments/:commentid/$put$ | target: CommentController.updateComment() | description: 更新指定主键的Comment信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/comments/$post$ | target: CommentController.addComment() | description: 添加新Comment信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/comments/:commentid/$delete$ | target: CommentController.deleteComment() | description: 更新指定主键的Comment信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/comments/:commentid/$get$ | target: CommentController.getComment() | description: 查询指定主键的Comment信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/stores/:storeid/$get$ | target: StoreController.getStore() | description: 查询指定主键的Store信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/stores/:storeid/$delete$ | target: StoreController.deleteStore() | description: 更新指定主键的Store信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/stores/:storeid/$put$ | target: StoreController.updateStore() | description: 更新指定主键的Store信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/stores/$post$ | target: StoreController.addStore() | description: 添加新Store信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/contacts/$post$ | target: ContactController.addContact() | description: 添加新Contact信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/contacts/:contactid/$put$ | target: ContactController.updateContact() | description: 更新指定主键的Contact信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/contacts/:contactid/$delete$ | target: ContactController.deleteContact() | description: 更新指定主键的Contact信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/contacts/:contactid/$get$ | target: ContactController.getContact() | description: 查询指定主键的Contact信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/orderdetails/:orderdetailid/$put$ | target: OrderdetailController.updateOrderdetail() | description: 更新指定主键的Orderdetail信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/orderdetails/:orderdetailid/$delete$ | target: OrderdetailController.deleteOrderdetail() | description: 更新指定主键的Orderdetail信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/orderdetails/$post$ | target: OrderdetailController.addOrderdetail() | description: 添加新Orderdetail信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/orderdetails/:orderdetailid/$get$ | target: OrderdetailController.getOrderdetail() | description: 查询指定主键的Orderdetail信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/clubbers/:openid/$put$ | target: ClubberController.updateClubber() | description: 更新指定主键的Clubber信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/clubbers/:openid/$delete$ | target: ClubberController.deleteClubber() | description: 更新指定主键的Clubber信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/clubbers/:openid/$get$ | target: ClubberController.getClubber() | description: 查询指定主键的Clubber信息
八月 20, 2015 10:30:01 上午 cn.jfast.framework.web.api.ApiContext info
信息: [jfast-1.1.1] load api ---- path: /api/v1/clubbers/$post$ | target: ClubberController.addClubber() | description: 添加新Clubber信息
八月 20, 2015 10:30:02 上午 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
八月 20, 2015 10:30:02 上午 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
八月 20, 2015 10:30:02 上午 org.apache.catalina.startup.Catalina start
信息: Server startup in 2784 ms

 

          

 

  • 大小: 37.2 KB
  • 大小: 23 KB
  • 大小: 25.9 KB
  • 大小: 11.2 KB
  • 大小: 16.3 KB
1
4
分享到:
评论
4 楼 p01197 2018-01-19  
老哥,我的mysql,连不上,报错信息是:Unknown system variable 'language
能解决下这问题吗? 我试过,数据库联链接,密码、等全对着,我还换了个本地库也没成功'
3 楼 toknowme 2015-08-20  
自己写的框架?
2 楼 陆地小神仙 2015-08-20  
恩恩,我会继续更新博客做用法说明的,谢谢支持!
1 楼 ynby369258 2015-08-20  
提供一个demo项目怎么用dao,controller就更好了

相关推荐

Global site tag (gtag.js) - Google Analytics