轻量级Java Web企业应用实战——Spring MVC+Spring+MyBatis整合开发

《轻量级Java Web企业应用实战――Spring MVC Spring MyBatis整合开发》不是一份“X天精通Java EE开发”的“心灵鸡汤”,这是一本令人生畏的“砖头”书。
1. 内容实际,针对性强
本书介绍的Java EE应用示例,采用了目前企业流行的开发架构,严格遵守Java EE开发规范,而不是将各种技术杂乱地糅合在一起号称Java EE。读者参考本书的架构,完全可以身临其境地感受企业实际开发。
2.框架源代码级的讲解,深入透彻
本书针对Spring MVC、Spring、MyBatis框架核心部分的源代码进行了讲解,不仅能帮助读者真正掌握框架的本质,而且能让读者参考优秀框架的源代码快速提高自己的技术功底。
本书介绍的源代码解读方法还可消除开发者对阅读框架源代码的恐惧,让开发者在遇到技术问题时能冷静分析问题,从框架源代码层次找到问题根源。
3.丰富、翔实的代码,面向实战
本书是面向实战的技术图书,坚信所有知识点必须转换成代码才能*终变成有效的生产力,因此本书为所有知识点提供了对应的可执行的示例代码。代码不仅有细致的注释,还结合理论对示例进行了详细的解释,真正让读者做到学以致用。
本书介绍了Java EE开发非常流行的三个开源框架:Spring MVC、Spring和MyBatis,其中Spring MVC、Spring用的是5.1版本,MyBatis用的是3.5版本。本书重点介绍了如何整合Spring MVC Spring MyBatis进行开发,内容主要包括三部分。*部分介绍Java EE开发的基础知识,以及如何搭建开发环境。第二部分详细讲解MyBatis、Spring和Spring MVC三个框架的用法,并从Eclipse IDE的使用上手,一步步带领读者深入三个框架的核心。这部分是本书的核心内容,因此也是重点部分。这部分并不是简单地讲授三个框架的基本用法,而是真正剖析它们在实际开发场景中面临的挑战及*实践,并对其诸多关键技术实现提供了源代码解读,这样既能加深读者对框架本质的理解,也能直接提升读者的Java功底。第三部分示范开发了一个包含7个表,表之间具有复杂的关联映射、继承映射等关系,且业务也相对复杂的工作流案例,帮助读者理论联系实际,将三个框架真正运用到实际开发中。该案例采用目前非常流行、规范的Java EE架构,整个应用分为领域对象层、Mapper(DAO)。层、业务逻辑层、MVC层和视图层,各层之间分层清晰,层与层之间以松耦合的方式组织在一起。该案例既提供了与IDE无关的、基于Ant管理的项目源代码,也提供了基于Eclipse IDE的项目源代码,*限度地满足读者的需求。本书配有读者答疑交流群,读者可通过扫描本书封面勒口上的二维码,按照指引加入,本书作者将通过交流群提供线上不定期答疑服务。
李刚,十余年软件开发从业经验,疯狂软件教育中心教学总监。疯狂Java实训营创始人,疯狂Java体系原创图书作者。广东技术师范学院计算机科学系兼职副教授,CSDN特邀讲师。培训的学生已在腾讯、阿里、华为、IBM、网易、唯品会、电信盈科等名企就职。国内知名高端IT技术图书作家,已出版《疯狂Java讲义》《疯狂Android讲义》《轻量级Java EE企业应用实战》《疯狂前端开发讲义》《疯狂HTML5/CSS3/JavaScript讲义》等著作。其中疯狂Java体系图书均已沉淀多年,赢得极高的市场认同,多次重印,多部著作印刷数量超过10万册,并被多所“985”“211”院校选作教材,部分图书已被翻译成繁体中文版,授权到中国台湾地区。
1.1 Java EE应用概述 2
1.1.1 Java EE应用的分层模型 2
1.1.2 Java EE应用的组件 3
1.1.3 Java EE应用的结构和优势 4
1.1.4 常用的Java EE服务器 4
1.2 轻量级Java EE应用相关技术 5
1.2.1 JSP、Servlet 4.x和JavaBean及替代技术 5
1.2.2 Spring MVC及替代技术 6
1.2.3 MyBatis及替代技术 6
1.2.4 Spring及替代技术 7
1.3 Tomcat的下载和安装 8
1.3.1 安装Tomcat服务器 8
1.3.2 配置Tomcat的服务端口 9
经过多年沉淀,Java EE平台已经成为电信、金融、电子商务、保险、证券等各行业的大型应用系统的开发平台。在企业级应用的开发选择上,.NET已趋式微,PHP通常只用于开发一些企业展示站点或小型应用,因此这些开发语言、开发平台基本上已无法与Java EE进行对抗了。
目前轻量级Java EE企业开发平台中核心的框架是Spring,而MVC框架大致存在两个选择:Spring MVC或Struts 2。由于技术方面的原因,Struts 2也渐趋没落;持久层框架则可选择JPA/Hibernate、MyBatis或Spring Data。
一般来说,JPA/Hibernate属于全自动的ORM框架,使用它可以非常方便地操作底层数据库,开发者无须直接编写SQL语句;而MyBatis则属于半自动的SQL Mapping框架,它依然要求开发者自己编写SQL语句。MyBatis的主要功能就是帮助开发者执行SQL语句,并将SQL查询结果映射成Java对象。
由此可见,MyBatis有它自己的优势:上手门槛低。即使是初级的Java开发者,上手MyBatis也很简单——直接把MyBatis当成单表数据库操作工具来用即可(在实际开发中确实有一些项目就是这么干的);而高级开发者依然可以利用MyBatis的关联映射和继承映射,而且可以灵活地对SQL语句进行优化,从而提高应用的数据库访问性能。
Shipping Overview:
• Shipping: Standard Domestic Shipping within the United States charges first item USD 6.99 and additional item USD 3.0 each. Standard International Shipping from United Kingdom, Germany, Italian and Japan to the United States charges first item USD 11.99 and additional item USD 4.0 each.
• Import Duty: Everymarket collects applicable duties and taxes on goods imported into the U.S. at checkout, it's calculated based on the goods value multiply by the rate. For United Kingdom and China goods is 10%, Germany, Italian and Japan goods is 15%. We are committed to making your U.S. shopping experience simple and transparent. The method of delivery—either Delivered Duty Paid (DDP) or Delivered Duty Unpaid (DDU)—depends on whether duties and taxes are collected at the time of your purchase.
• Order Processing: Please allow 1-2 business days for order processing and preparation before shipment.
• Domestic Shipping: Orders within the U.S. are shipped via USPS or FedEx, depending on the origin of the product. Average transit times to the United States is 3 - 7 Business days and average transit times to International is 7 - 14 Business days
• International Shipping: Currently, we only ship within the USA.
• Tracking Information: Every order is trackable. You will receive a tracking number once your order has been shipped. Products may be shipped from various global fulfillment centers.
Shipping Delays:
Please note that shipping times may vary due to factors beyond our control, such as weather conditions, natural disasters, or peak holiday periods. While we strive to ensure timely delivery, the exact arrival time cannot be guaranteed and is managed by the shipping carrier.
Shipping Options:
-
Standard Delivery: Most orders are shipped within 3-7 business days. Larger items may utilize LTL shipping for safe handling.
-
Handling Time: We handle shipments on business days (Monday - Friday), with a preparation time of 1-2 days.
-
Additional Charges: Some items require additional shipping charges due to their size, weight, or special handling. These charges are specified on the product pages and are not eligible for shipping discounts.
-
Exclusions: Gift cards, packaging, taxes, and prior purchases do not count toward the minimum purchase requirement for free shipping. This offer is valid only for shipments to U.S. addresses, including Puerto Rico.
Delivery Details:
-
Estimates: Standard shipping within the US typically takes 3-7 business days. These are estimates and not guarantees.
-
Shipping Restrictions: We ship to all 50 states, Washington, DC, U.S. territories, and APO/FPO/DPO addresses. Shipping options vary based on the delivery address.
-
Remote Areas: Shipments to remote areas may incur additional charges or require pickup from a nearby shipping partner’s location.
Shipping Confirmation:
You will receive a shipping confirmation email with a tracking number as soon as your order is dispatched. If you do not receive this email immediately, please be assured that your items will arrive within the estimated delivery window provided at checkout.
Order Modifications:
If you need to cancel or modify your order, please contact our customer support immediately.
Issues with Delivery:
If your order shows as delivered but you have not received it, please contact the shipping carrier directly to resolve the issue. For persistent problems, contact our customer service at cs@everymarket.com.
Customer Support:
Our team is available 24/7 to assist you with any questions or concerns regarding your order. We are committed to ensuring a smooth shopping experience.
Return & Refund Policy Overview
Please review our return and refund policies below to ensure a smooth transaction process.
Return Policy
-
Duration: You have 30 days from receiving your item to initiate a return.
-
Condition: Items must be unworn, unwashed, with original tags and packaging intact.
-
Shipping Costs:
- If your return is approved due to a defective, damaged, or incorrect item, we will provide a prepaid return shipping label at no cost.
- If the item has no quality issues and matches the product listing and description, please contact our Customer Service team before returning it. Once your return is authorized, you must return the item according to the provided instructions. In this case, the return shipping cost is the customer's responsibility.
- We are not responsible for return shipping costs for items returned without prior authorization. -
Packaging: Ensure returned items are well-packaged to avoid damage during transit.
-
Tracking: Use a trackable and insured shipping method as we are not liable for items lost or damaged on return.
-
Initiating a Return: Contact us at cs@everymarket.com to start your return. We will provide a return shipping label and instructions upon approval. Returns without prior approval will not be accepted.
How to Return
-
Method: Returns must be sent back by mail to the address provided in the return instructions.
Return Label
-
Please contact us to get return labels.
Product Conditions for Return
-
Eligible Products: Returns are only accepted for items in new condition.
Nonreturnable Items
Certain items are not eligible for return:
-
Electronic devices after 30 days (e.g., computers, laptops, Kindles)
-
Gift cards, prepaid game cards
-
Perishable goods, live insects, some jewelry, some health and personal care items
-
Customized or personalized products
-
Items with special shipping restrictions
Refund Policy
-
Window: Eligible products may be returned within 30 days of delivery for a refund.
-
Refund Method: Refunds are processed to the original payment method or as store credit for items purchased with gift cards.
-
Processing Time: Refunds are processed within 3-5 business days after we receive the return; please allow additional time for shipping and bank processing.
Claims
Inspect your order upon arrival and report any defects, damages, or incorrect items immediately to allow us to address the issue. For claims, contact our support team with details of the issue.
Exchange Policy
For the quickest service, return your original item and place a new order for the desired product once your return is accepted.
Return Address
EveryMarket Customer Service 2101 E Terra Ln, O'Fallon, MO 63366
Customer Support
Available 24/7 for any questions or assistance needed:
-
Phone: +1 (800) 660-3783
-
Email: cs@everymarket.com

《轻量级Java Web企业应用实战――Spring MVC Spring MyBatis整合开发》不是一份“X天精通Java EE开发”的“心灵鸡汤”,这是一本令人生畏的“砖头”书。
1. 内容实际,针对性强
本书介绍的Java EE应用示例,采用了目前企业流行的开发架构,严格遵守Java EE开发规范,而不是将各种技术杂乱地糅合在一起号称Java EE。读者参考本书的架构,完全可以身临其境地感受企业实际开发。
2.框架源代码级的讲解,深入透彻
本书针对Spring MVC、Spring、MyBatis框架核心部分的源代码进行了讲解,不仅能帮助读者真正掌握框架的本质,而且能让读者参考优秀框架的源代码快速提高自己的技术功底。
本书介绍的源代码解读方法还可消除开发者对阅读框架源代码的恐惧,让开发者在遇到技术问题时能冷静分析问题,从框架源代码层次找到问题根源。
3.丰富、翔实的代码,面向实战
本书是面向实战的技术图书,坚信所有知识点必须转换成代码才能*终变成有效的生产力,因此本书为所有知识点提供了对应的可执行的示例代码。代码不仅有细致的注释,还结合理论对示例进行了详细的解释,真正让读者做到学以致用。
本书介绍了Java EE开发非常流行的三个开源框架:Spring MVC、Spring和MyBatis,其中Spring MVC、Spring用的是5.1版本,MyBatis用的是3.5版本。本书重点介绍了如何整合Spring MVC Spring MyBatis进行开发,内容主要包括三部分。*部分介绍Java EE开发的基础知识,以及如何搭建开发环境。第二部分详细讲解MyBatis、Spring和Spring MVC三个框架的用法,并从Eclipse IDE的使用上手,一步步带领读者深入三个框架的核心。这部分是本书的核心内容,因此也是重点部分。这部分并不是简单地讲授三个框架的基本用法,而是真正剖析它们在实际开发场景中面临的挑战及*实践,并对其诸多关键技术实现提供了源代码解读,这样既能加深读者对框架本质的理解,也能直接提升读者的Java功底。第三部分示范开发了一个包含7个表,表之间具有复杂的关联映射、继承映射等关系,且业务也相对复杂的工作流案例,帮助读者理论联系实际,将三个框架真正运用到实际开发中。该案例采用目前非常流行、规范的Java EE架构,整个应用分为领域对象层、Mapper(DAO)。层、业务逻辑层、MVC层和视图层,各层之间分层清晰,层与层之间以松耦合的方式组织在一起。该案例既提供了与IDE无关的、基于Ant管理的项目源代码,也提供了基于Eclipse IDE的项目源代码,*限度地满足读者的需求。本书配有读者答疑交流群,读者可通过扫描本书封面勒口上的二维码,按照指引加入,本书作者将通过交流群提供线上不定期答疑服务。
李刚,十余年软件开发从业经验,疯狂软件教育中心教学总监。疯狂Java实训营创始人,疯狂Java体系原创图书作者。广东技术师范学院计算机科学系兼职副教授,CSDN特邀讲师。培训的学生已在腾讯、阿里、华为、IBM、网易、唯品会、电信盈科等名企就职。国内知名高端IT技术图书作家,已出版《疯狂Java讲义》《疯狂Android讲义》《轻量级Java EE企业应用实战》《疯狂前端开发讲义》《疯狂HTML5/CSS3/JavaScript讲义》等著作。其中疯狂Java体系图书均已沉淀多年,赢得极高的市场认同,多次重印,多部著作印刷数量超过10万册,并被多所“985”“211”院校选作教材,部分图书已被翻译成繁体中文版,授权到中国台湾地区。
1.1 Java EE应用概述 2
1.1.1 Java EE应用的分层模型 2
1.1.2 Java EE应用的组件 3
1.1.3 Java EE应用的结构和优势 4
1.1.4 常用的Java EE服务器 4
1.2 轻量级Java EE应用相关技术 5
1.2.1 JSP、Servlet 4.x和JavaBean及替代技术 5
1.2.2 Spring MVC及替代技术 6
1.2.3 MyBatis及替代技术 6
1.2.4 Spring及替代技术 7
1.3 Tomcat的下载和安装 8
1.3.1 安装Tomcat服务器 8
1.3.2 配置Tomcat的服务端口 9
经过多年沉淀,Java EE平台已经成为电信、金融、电子商务、保险、证券等各行业的大型应用系统的开发平台。在企业级应用的开发选择上,.NET已趋式微,PHP通常只用于开发一些企业展示站点或小型应用,因此这些开发语言、开发平台基本上已无法与Java EE进行对抗了。
目前轻量级Java EE企业开发平台中核心的框架是Spring,而MVC框架大致存在两个选择:Spring MVC或Struts 2。由于技术方面的原因,Struts 2也渐趋没落;持久层框架则可选择JPA/Hibernate、MyBatis或Spring Data。
一般来说,JPA/Hibernate属于全自动的ORM框架,使用它可以非常方便地操作底层数据库,开发者无须直接编写SQL语句;而MyBatis则属于半自动的SQL Mapping框架,它依然要求开发者自己编写SQL语句。MyBatis的主要功能就是帮助开发者执行SQL语句,并将SQL查询结果映射成Java对象。
由此可见,MyBatis有它自己的优势:上手门槛低。即使是初级的Java开发者,上手MyBatis也很简单——直接把MyBatis当成单表数据库操作工具来用即可(在实际开发中确实有一些项目就是这么干的);而高级开发者依然可以利用MyBatis的关联映射和继承映射,而且可以灵活地对SQL语句进行优化,从而提高应用的数据库访问性能。
Shipping Overview:
• Shipping: Standard Domestic Shipping within the United States charges first item USD 6.99 and additional item USD 3.0 each. Standard International Shipping from United Kingdom, Germany, Italian and Japan to the United States charges first item USD 11.99 and additional item USD 4.0 each.
• Import Duty: Everymarket collects applicable duties and taxes on goods imported into the U.S. at checkout, it's calculated based on the goods value multiply by the rate. For United Kingdom and China goods is 10%, Germany, Italian and Japan goods is 15%. We are committed to making your U.S. shopping experience simple and transparent. The method of delivery—either Delivered Duty Paid (DDP) or Delivered Duty Unpaid (DDU)—depends on whether duties and taxes are collected at the time of your purchase.
• Order Processing: Please allow 1-2 business days for order processing and preparation before shipment.
• Domestic Shipping: Orders within the U.S. are shipped via USPS or FedEx, depending on the origin of the product. Average transit times to the United States is 3 - 7 Business days and average transit times to International is 7 - 14 Business days
• International Shipping: Currently, we only ship within the USA.
• Tracking Information: Every order is trackable. You will receive a tracking number once your order has been shipped. Products may be shipped from various global fulfillment centers.
Shipping Delays:
Please note that shipping times may vary due to factors beyond our control, such as weather conditions, natural disasters, or peak holiday periods. While we strive to ensure timely delivery, the exact arrival time cannot be guaranteed and is managed by the shipping carrier.
Shipping Options:
-
Standard Delivery: Most orders are shipped within 3-7 business days. Larger items may utilize LTL shipping for safe handling.
-
Handling Time: We handle shipments on business days (Monday - Friday), with a preparation time of 1-2 days.
-
Additional Charges: Some items require additional shipping charges due to their size, weight, or special handling. These charges are specified on the product pages and are not eligible for shipping discounts.
-
Exclusions: Gift cards, packaging, taxes, and prior purchases do not count toward the minimum purchase requirement for free shipping. This offer is valid only for shipments to U.S. addresses, including Puerto Rico.
Delivery Details:
-
Estimates: Standard shipping within the US typically takes 3-7 business days. These are estimates and not guarantees.
-
Shipping Restrictions: We ship to all 50 states, Washington, DC, U.S. territories, and APO/FPO/DPO addresses. Shipping options vary based on the delivery address.
-
Remote Areas: Shipments to remote areas may incur additional charges or require pickup from a nearby shipping partner’s location.
Shipping Confirmation:
You will receive a shipping confirmation email with a tracking number as soon as your order is dispatched. If you do not receive this email immediately, please be assured that your items will arrive within the estimated delivery window provided at checkout.
Order Modifications:
If you need to cancel or modify your order, please contact our customer support immediately.
Issues with Delivery:
If your order shows as delivered but you have not received it, please contact the shipping carrier directly to resolve the issue. For persistent problems, contact our customer service at cs@everymarket.com.
Customer Support:
Our team is available 24/7 to assist you with any questions or concerns regarding your order. We are committed to ensuring a smooth shopping experience.
Return & Refund Policy Overview
Please review our return and refund policies below to ensure a smooth transaction process.
Return Policy
-
Duration: You have 30 days from receiving your item to initiate a return.
-
Condition: Items must be unworn, unwashed, with original tags and packaging intact.
-
Shipping Costs:
- If your return is approved due to a defective, damaged, or incorrect item, we will provide a prepaid return shipping label at no cost.
- If the item has no quality issues and matches the product listing and description, please contact our Customer Service team before returning it. Once your return is authorized, you must return the item according to the provided instructions. In this case, the return shipping cost is the customer's responsibility.
- We are not responsible for return shipping costs for items returned without prior authorization. -
Packaging: Ensure returned items are well-packaged to avoid damage during transit.
-
Tracking: Use a trackable and insured shipping method as we are not liable for items lost or damaged on return.
-
Initiating a Return: Contact us at cs@everymarket.com to start your return. We will provide a return shipping label and instructions upon approval. Returns without prior approval will not be accepted.
How to Return
-
Method: Returns must be sent back by mail to the address provided in the return instructions.
Return Label
-
Please contact us to get return labels.
Product Conditions for Return
-
Eligible Products: Returns are only accepted for items in new condition.
Nonreturnable Items
Certain items are not eligible for return:
-
Electronic devices after 30 days (e.g., computers, laptops, Kindles)
-
Gift cards, prepaid game cards
-
Perishable goods, live insects, some jewelry, some health and personal care items
-
Customized or personalized products
-
Items with special shipping restrictions
Refund Policy
-
Window: Eligible products may be returned within 30 days of delivery for a refund.
-
Refund Method: Refunds are processed to the original payment method or as store credit for items purchased with gift cards.
-
Processing Time: Refunds are processed within 3-5 business days after we receive the return; please allow additional time for shipping and bank processing.
Claims
Inspect your order upon arrival and report any defects, damages, or incorrect items immediately to allow us to address the issue. For claims, contact our support team with details of the issue.
Exchange Policy
For the quickest service, return your original item and place a new order for the desired product once your return is accepted.
Return Address
EveryMarket Customer Service 2101 E Terra Ln, O'Fallon, MO 63366
Customer Support
Available 24/7 for any questions or assistance needed:
-
Phone: +1 (800) 660-3783
-
Email: cs@everymarket.com
Oops!
Sorry, it looks like some products are not available in selected quantity.

