搜尋
首頁Javajava教程詳解如何整合SpringMVC和mybatis

詳解如何整合SpringMVC和mybatis

May 08, 2017 pm 01:57 PM
java

这篇文章主要介绍了springmvc与mybatis实例详解的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下

MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis 。

一、逆向工程生成基础信息

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="testTables" targetRuntime="MyBatis3">
<commentGenerator>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3307/mybatis" userId="root"
passaspku.com/pc/softtech/office/word/" target="_blank"><u>word</u>="jalja">
</jdbcConnection>
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 
NUMERIC 类型解析为java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:生成PO类的位置 -->
<javaModelGenerator targetPackage="com.jalja.springmvc_mybatis.model.pojo"
targetProject=".\src">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- targetProject:mapper映射文件生成的位置 -->
<sqlMapGenerator targetPackage="com.jalja.springmvc_mybatis.mapper"
targetProject=".\src">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- targetPackage:mapper接口生成的位置 -->
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.jalja.springmvc_mybatis.mapper"
targetProject=".\src">
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- 指定数据库表 -->
<table tableName="items"></table>
<table tableName="orders"></table>
<table tableName="orderdetail"></table>
<table tableName="user"></table>
</context>
</generatorConfiguration> 
public static void main(String[] arhs) throws Exception{
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
File configFile = new File("src.main.resources/generator.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
}

二、springMVC与Mybatis整合 各个配置文件

1.项目结构

2、各个文件的核心代码

a.web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app 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" version="3.0"> 
<welcome-file-list> 
<welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value> classpath:spring/applicationContext-*.xml </param-value>
</context-param>
<listener> 
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 
<context-param> 
<param-name>log4jConfigLocation</param-name> 
<param-value>classpath:log4j.properties</param-value> 
</context-param> 
<context-param> 
<param-name>log4jRefreshInterval</param-name> 
<param-value>3000</param-value> 
</context-param> 
<listener> 
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> 
</listener> 
<!-- post请求乱码 -->
<filter>
<filter-name>SpringEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SpringEncodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping> 
<!-- springMvc前端控制器 --> 
<servlet> 
<servlet-name>springMvc</servlet-name> 
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
<init-param> 
<!-- 
contextConfigLocation加载 springMvc的配置文件(处理器适配器 ,映射器) 
如果不配置默认加载的是 /WEB-INF/servlet名称-servlet.xml(springMvc-servlet.xml)
-->
<param-name>contextConfigLocation</param-name> 
<param-value>classpath:spring/springmvc.xml</param-value> 
</init-param> 
<load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
<servlet-name>springMvc</servlet-name> 
<!--
1、*.do :DispatcherServlet 解析所有 *.do 结尾的访问
2、 / :DispatcherServlet解析所有请求(包括静态资源) 这种配置可以实现restful风格的url
3、/*: 这种配置最终要转发到一个jsp页面 
-->
<url-pattern>*.do</url-pattern> 
</servlet-mapping> 
<!-- springMvc前端控制器 RestFul 
<servlet> 
<servlet-name>springMvc_rest</servlet-name> 
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
<init-param> 
<param-name>contextConfigLocation</param-name> 
<param-value>classpath:spring/applicationContext-springmvc.xml</param-value> 
</init-param> 
<load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
<servlet-name>springMvc_rest</servlet-name> 
<url-pattern>/</url-pattern> 
</servlet-mapping> 
-->
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>

b、config/mybatis/applicationContext-mybatis.xml

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> 
<configuration> 
<!-- 
各个属性
properties:
setting(全局配置参数配置):mybatis运行时可以调整一些运行参数 例如:开启二级缓存、开启延迟加载 
typeAliases(类型别名): 在mapper.xml中定义parameterType 参数类型 resultType 返回类型时 
需要指定类型的路径 不方便开发,我们开一针对 这些类型给其指定别名
typeHandler(类型处理器):在mybatis 中是通过typeHandler 完成 jdbc类型与java类型的转化 ,mybatis 提供的处理器已可满足 开发需求 
objectFactory(对象工厂):
plugins(插件):
environments(环境集合属性对象):
environment(环境子属性对象):
transactionManager(事务管理):
dataSource(数据源):
mappers(映射器): 
-->
<!-- 对事务的管理和连接池的配置 --> 
<!-- 延迟加载 -->
<settings>
<!-- 打开延迟加载 -->
<setting name="lazyLoadingEnabled" value="true"/>
<!-- 积极加载改为消极加载 -->
<setting name="aggressiveLazyLoading" value="false"/>
<!-- 开启二级缓存 -->
<setting name="cacheEnabled" value="true"/>
</settings>
<typeAliases>
<!-- 针对单个别名定义 -->
<!-- <typeAlias type="com.jalja.myBatis.model.User" alias="user"/> -->
<!--批量别名的定义 mybatis 自动扫描包中的类 别名就是类名(首字母大小写都可以) -->
<package name="com.jalja.springmvc_mybatis.model.pojo"/>
<package name="com.jalja.springmvc_mybatis.model.custom"/>
<package name="com.jalja.springmvc_mybatis.model.vo"/>
</typeAliases>
<!--加载映射文件 -->
<!-- <mappers> <mapper resource="com/jalja/spring_mybatis/mapper/UserMapper.xml"/> -->
<!-- 和spring整合后 可以去掉 
<package name="com.jalja.spring_mybatis.mapper"/> </mappers>-->
</configuration>

c、config/spring/applicationContext-dao.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.2.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/cache 
http://www.springframework.org/schema/cache/spring-cache-3.2.xsd">
<!-- 引入jdbc配置文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/> 
<!-- 对JDBC配置进行解密 
<bean id="propertyConfigurer" class="cn.com.sinobpo.project.wfjb.utils.EncryptablePropertyPlaceholderConfigurer"> 
<property name="locations">
<list>
<value>classpath:resources/config/jdbc.properties</value>
</list>
</property>
</bean> -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc_driverClassName}</value>
</property>
<property name="url">
<value>${jdbc_url}</value>
</property>
<property name="username">
<value>${jdbc_username}</value>
</property>
<property name="password">
<value>${jdbc_password}</value>
</property>
<!-- 连接池最大使用连接数 -->
<property name="maxActive">
<value>20</value>
</property>
<!-- 初始化连接大小 -->
<property name="initialSize">
<value>1</value>
</property>
<!-- 获取连接最大等待时间 -->
<property name="maxWait">
<value>60000</value>
</property>
<!-- 连接池最大空闲 -->
<property name="maxIdle">
<value>20</value>
</property>
<!-- 连接池最小空闲 -->
<property name="minIdle">
<value>3</value>
</property>
<!-- 自动清除无用连接 -->
<property name="removeAbandoned">
<value>true</value>
</property>
<!-- 清除无用连接的等待时间 -->
<property name="removeAbandonedTimeout">
<value>180</value>
</property>
<!-- 连接属性 -->
<property name="connectionProperties">
<value>clientEncoding=UTF-8</value>
</property>
</bean>
<!-- spring和MyBatis完美整合 --> 
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> 
<property name="dataSource" ref="dataSource"/> 
<property name="configLocation" value="classpath:mybatis/applicationContext-mybatis.xml"/>
</bean> 
<!--使用 mapper 代理 的方式 mapper扫描器 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> 
<!-- 扫描包路径 如果需要扫描多个包 ,中间使用半角逗号隔开 -->
<property name="basePackage" value="com.jalja.springmvc_mybatis.mapper"/> 
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> 
</bean> 
<!--声明式 事务管理 使用jdbc的事务管理 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 配置事务通知-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="get*" propagation="SUPPORTS" read-only="true"/> 
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/> 
</tx:attributes>
</tx:advice>
<!-- 配置事务的切点,并把事务切点和事务属性不关联起来AOP -->
<aop:config>
<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.jalja.springmvc_mybatis.service.impl.*.*(..))"/>
</aop:config>
</beans>

d、config/spring/applicationContext-service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.2.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/cache 
http://www.springframework.org/schema/cache/spring-cache-3.2.xsd">
<bean id="itemsService" class="com.jalja.springmvc_mybatis.service.impl.ItemsServiceImpl"></bean>
</beans>

e、config/spring/springmvc.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/cache 
http://www.springframework.org/schema/cache/spring-cache-3.2.xsd">
<!--注解 处理器 映射器 -->
<!-- 映射器 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping springmvc3.1以前--> 
<!-- 映射器 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping springmvc3.1以后 -->
<!-- 适配器 org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter springmvc3.1以前--> 
<!-- 适配器 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter springmvc3.1以后 -->
<!--配置映射器和 适配器 
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/> -->
<!-- 开启注解 映射器和 适配器 这种方式默认加载了很多参数绑定的方法 例如 json转换解析器-->
<mvc:annotation-driven/>
<!-- 配置 Handler
<bean class="com.jalja.springmvc_mybatis.controller.UserController"/>-->
<!-- 注解 配置 基于组建扫描的方式 -->
<context:component-scan base-package="com.jalja.springmvc_mybatis.controller" />
<!-- 配置自定义参数解析器 -->
<mvc:annotation-driven conversion-service="conversionService"/>
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="converters">
<list>
<!-- 日期类型转换 -->
<bean class="com.jalja.springmvc_mybatis.converter.CustomDateConverter"></bean>
</list>
</property>
</bean>
<!-- 全局异常处理器 -->
<bean class="com.jalja.springmvc_mybatis.exception.CustomExceptionResolver"/>
<!-- 文件上传 -->
<!-- 支持上传文件 --> 
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 文件大小 5M -->
<property name="maxUploadSize" value="5242880"/>
</bean> 
<!-- 使用 restFul 风格 编程 照成 的 静态资源 访问 问题 -->
<!-- <mvc:resources mapping="/js/**" location="/resources/js/"/> -->
<!-- springMVC拦截器的配置 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<bean class="com.jalja.springmvc_mybatis.interceptor.LoginInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
<!-- 视图映射 jsp解析 默认使用jstl-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 默认使用 -->
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean> 
</beans>

f、config/jdbc.properties

jdbc_driverClassName=com.mysql.jdbc.Driver
jdbc_url=jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=UTF-8
jdbc_username=root
jdbc_password=111111

g、config/log4j.properties

#在开发环境下的日志级别 要设置成debug,生成环境设置成info 或error
log4j.rootLogger=debug, stdout
log4j.logger.org.apache.ibatis=debug
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

h、com/jalja/springmvc_mybatis/controller/ItemsController.java

package com.jalja.springmvc_mybatis.controller;
import java.io.File;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.jalja.springmvc_mybatis.exception.CustomException;
import com.jalja.springmvc_mybatis.model.custom.ItemsCustom;
import com.jalja.springmvc_mybatis.service.ItemsService;
/**
* 商品 
* @author PC003
*conterver参数转换器 springMvc提供了很多参数转换器
*/
@Controller
@RequestMapping("/items") //窄化请求映射
public class ItemsController {
@Autowired ItemsService itemsService;
@RequestMapping(value="/findItemsList")
public String findItemsList(Model model) throws Exception{
List<ItemsCustom> itemsList=itemsService.findItemsList(null);
System.out.println(itemsList);
model.addAttribute("itemsList", itemsList);
return "itemsList";
}
@RequestMapping(value="/editItems", method={RequestMethod.POST,RequestMethod.GET}) //限制Http请求方式
//@RequestParam 将请求参数 与 形式参数进行绑定 required:指定属性必须传入值 defaultValue:设置默认值
public String editItems(Model model, @RequestParam(value="id",required=true,defaultValue="0") Integer itemsId) throws Exception{
ItemsCustom itemsCustom=itemsService.findItemsById(itemsId);
if(itemsCustom==null){
throw new CustomException("商品不存在");
}
model.addAttribute("itemsCustom", itemsCustom);
return "editItems";
}
@RequestMapping(value="/updateItems")
public String editItemsSubmit(Integer id,ItemsCustom itemsCustom,MultipartFile itemsPic) throws Exception{
String uploadFileName=itemsPic.getOriginalFilename();//获取上传的文件名
if(itemsPic!=null && uploadFileName!=null && !uploadFileName.equals("")){
String imagesPath="E:\\develop\\upload\\images\\";
String newFileName=UUID.randomUUID()+uploadFileName.substring(uploadFileName.lastIndexOf("."),uploadFileName.length());
File newFile=new File(imagesPath+newFileName);
itemsPic.transferTo(newFile);//将内存中的数据写入磁盘
itemsCustom.setPic(newFileName);
}
itemsService.updateItemsById(id, itemsCustom);
return "redirect:findItemsList.do"; //重定向
}
//JSON的使用 @ResponseBody:将对像转json输出 @RequestBody:将请求参数转 java对象
@RequestMapping(value="/jsonRequest")
public @ResponseBody ItemsCustom jsonRequest(@RequestBody ItemsCustom itemsCustom) throws Exception{
return itemsCustom;
}
//RestFul 风格 编程 /restFulRequest/{id}:表示将这个位置的参数传到 @PathVariable 指定的名称中
@RequestMapping(value="/restFulRequest/{id}")
public @ResponseBody ItemsCustom restFulRequest(@PathVariable("id") Integer id) throws Exception{
ItemsCustom itemsCustom=itemsService.findItemsById(id);
return itemsCustom;
}
}

【相关推荐】

1.Java免费视频教程

2.全面解析Java注解

3.FastJson教程手册

以上是詳解如何整合SpringMVC和mybatis的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
如何將Maven或Gradle用於高級Java項目管理,構建自動化和依賴性解決方案?如何將Maven或Gradle用於高級Java項目管理,構建自動化和依賴性解決方案?Mar 17, 2025 pm 05:46 PM

本文討論了使用Maven和Gradle進行Java項目管理,構建自動化和依賴性解決方案,以比較其方法和優化策略。

如何使用適當的版本控制和依賴項管理創建和使用自定義Java庫(JAR文件)?如何使用適當的版本控制和依賴項管理創建和使用自定義Java庫(JAR文件)?Mar 17, 2025 pm 05:45 PM

本文使用Maven和Gradle之類的工具討論了具有適當的版本控制和依賴關係管理的自定義Java庫(JAR文件)的創建和使用。

如何使用咖啡因或Guava Cache等庫在Java應用程序中實現多層緩存?如何使用咖啡因或Guava Cache等庫在Java應用程序中實現多層緩存?Mar 17, 2025 pm 05:44 PM

本文討論了使用咖啡因和Guava緩存在Java中實施多層緩存以提高應用程序性能。它涵蓋設置,集成和績效優勢,以及配置和驅逐政策管理最佳PRA

如何將JPA(Java持久性API)用於具有高級功能(例如緩存和懶惰加載)的對象相關映射?如何將JPA(Java持久性API)用於具有高級功能(例如緩存和懶惰加載)的對象相關映射?Mar 17, 2025 pm 05:43 PM

本文討論了使用JPA進行對象相關映射,並具有高級功能,例如緩存和懶惰加載。它涵蓋了設置,實體映射和優化性能的最佳實踐,同時突出潛在的陷阱。[159個字符]

Java的類負載機制如何起作用,包括不同的類載荷及其委託模型?Java的類負載機制如何起作用,包括不同的類載荷及其委託模型?Mar 17, 2025 pm 05:35 PM

Java的類上載涉及使用帶有引導,擴展程序和應用程序類負載器的分層系統加載,鏈接和初始化類。父代授權模型確保首先加載核心類別,從而影響自定義類LOA

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器