ssh 中用註解和不用註解兩重sessionFactory獲得方式
在Hibernate Annotation Spring 整合的時候出現的:
解決方法:
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- results in a setDriverClassName(String) call -->
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db_ajax"/>
<property name="username" value="123"/>
<property name="password" value="123"/>
</bean>
<bean id="factory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
<property name="dataSource" ref="myDataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.yin.hibernate.GuestBook</value>
</list>
</property>
在 Hibernate distribution Spring整合時
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- results in a setDriverClassName(String) call -->
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="url" value="jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db_ajax"/>
<property name="username" value="123"/>
<property name="password" value="123"/>
</bean>
<bean id="factory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean
<property name="dataSource" ref="myDataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/yin/hibernate/GuestBook.hbm.xml</value>
</list>
</property>
</bean>
上面只需要注意紅色的部分就行了
相關推薦
ssh 中用註解和不用註解兩重sessionFactory獲得方式
在Hibernate Annotation Spring 整合的時候出現的: 解決方法: <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
SSH整合步驟之註解和非註解
加入jar struts rep imp dialect 整合struts com ssp rda spring整合hibernate 加入jar包 加入spring和aop所需必須包 加入hibernate的必須包 spring整合hibernate的必須包 org.sp
SpringMvc 上傳excel(註解和非註解兩種方式)
1、第一種方式: A:JSP頁面: <form name="importForm" action="${ctx }/service/userService/BatchImport.do" method="post" enctype="multipar
Spring AOP 之AspectJ註解和XML配置兩種實現(Maven構建)
xml配置 1.介面和實現類 public interface UserManager { public String findUserById(int userId); } @Service public class UserManage
【SSH】註解和非註解的形式配置Spring
一、前言 在框架學習中,我們學到了很多東西。spring 2.5 的一大增強就是引入了很多註釋類,現在您已經可以使用註釋配置完成大部分 XML 配置的功能。在這篇文章裡,我們將向您講述使用
ssh2項目整合 struts2.1+hibernate3.3+spring3 基於hibernate註解和struts2註解
模塊 port aware -- ids tle des 項目 @service 項目文件夾結構例如以下: 核心配置文件: web.xml <?xml version="1.0" encoding="UTF-8"
組合註解和元註解
從 spring 2.0 開始為了響應 jdk1.5推出的註解功能, spring 開始大量加入註解來替代xml 配置. 元註解:即可註解到其他註解的註解. 組合註解:即被註解的註解. 示例: 組合註解: package com.pangu.annotation; impo
Spring Boot 2 @EnableWebMvc 註解和@EnableSpringDataWebSupport 註解使用說明
1. @EnableWebMvc使用說明 @EnableWebMvc 只能新增到一個@Configuration配置類上,用於匯入Spring Web MVC configuration 可以有多個@Configuration類來實現WebMvcConfigurer,以定製
springmvc.xml(註解和非註解的詳細配置)
註解和非註解的一些配置說明,方便自己以後檢視! 非註解如下: <!--非註解開始 --> <!--非註解的處理器介面卡 --> <!-- 處理器介面卡的配置 所有的處理器介面卡都需要實現HandlerAdapter介面 -->
SpringBoot+MyBatis中自動根據@Table註解和@Column註解生成ResultMap
while ash 標記 ast protoc 第一個 ann element conf 其實我一點都不想用mybatis,好多地方得自己寫,比如這裏。 使用mybatis要寫大量的xml,煩的一批。最煩人的莫過於寫各種resultmap,就是數據庫字段和實體屬性做映射。
教你如何建立註解和淺析註解原理
前言: 註解在目前而言最主流的應用:代替配置檔案 關於配置檔案與註解開發的優缺點: 註解優點:開發效率高 成本低 註解缺點:耦合性大 並且不利於後期維護 常見的註解舉例: @Override:告知編譯器此方法是覆蓋父類的 @Deprecated:標註過時 @
Spring5:@Autowired註解、@Resource註解和@Service註解
什麼是註解 傳統的Spring做法是使用.xml檔案來對bean進行注入或者是配置aop、事物,這麼做有兩個缺點: 1、如果所有的內容都配置在.xml檔案中,那麼.xml檔案將會十分龐大;如果按需求分開.xml檔案,那麼.xml檔案又會非常多。總之這將導致配置檔案的可讀性
@ResponseBody註解和@RequestBody註解
在Spring中使用@ResponseBody註解可以將方法返回的物件序列化成JSON, 將返回的物件轉成json字串返回, 與下面的@ResponseBody註解功能相反. 在Controll
Autowried註解和Resource註解的區別
過程 情況 通過 找到 如何 依賴註入 方式 null 部分 目錄 概述 Autowried Resource Resource註解的裝配順序 總結 概述 在使用Spring框架的過程中, 依賴註入是必須的, 大多時候會使用Autowried註解來進行依賴註入, 但是
Spring @Autowired註解、@Resource註解和@Service註解
什麼是註解 傳統的Spring做法是使用.xml檔案來對bean進行注入或者是配置aop、事物,這麼做有兩個缺點: 1、如果所有的內容都配置在.xml檔案中,那麼.xml檔案將會十分龐大;如果按需求分開.xml檔案,那麼.xml檔案又會非常多。總之這將導致配置檔案的可讀性與
Spring的@Autowired註解、@Resource註解和@Service註解
什麼是註解 傳統的Spring做法是使用.xml檔案來對bean進行注入或者是配置aop、事物,這麼做有兩個缺點: 1、如果所有的內容都配置在.xml檔案中,那麼.xml檔案將會十分龐大;如果按需求分開.xml檔案,那麼.xml檔案又會非常多。總之這將導致配置檔案的可讀性與可維護性變得很低 2、在開發中在.
@Resource註解和@Autowired註解的區別
@Resource註解(javax.annotation.Resource;)由sun公司開發而成;@Resource註解預設按照輸入的名稱進行bean裝配 @Autowired註解(org.springframework.beans.factory.annotation.
Spring中的@Controller註解和@RestController註解的相同點和不同點
相同點: 1:@Controller和@RestController兩個註解的生命週期都會持續到程式執行時; 2:@Controller和@RestController都用來表示當前類是一個控制器servlet 不同點: 1:@RestController是@Control
Spring框架註解:@Autowired註解、@Resource註解和@Service註解
什麼是註解傳統的Spring做法是使用.xml檔案來對bean進行注入或者是配置aop、事物,這麼做有兩個缺點:1、如果所有的內容都配置在.xml檔案中,那麼.xml檔案將會十分龐大;如果按需求分開.xml檔案,那麼.xml檔案又會非常多。總之這將導致配置檔案的可讀性與可維護
@Component註解和@Configuration註解的之間的區別
直白的說Component包含了Configuration的所用註解:Configuration和Component都是註解在類上的,Configuration類中的方法成員變數是@Value註解,方法上的註解是@BeanComponent類中的方法和成員變數沒有任何限制