春データJPAの構成に依存+

ばねデータJPAばねORMフレームワークは、仕様JPAアプリケーションフレームワークJPAに基づいてパッケージに基づいています

その依存関係を追加します。

<プロパティ> 
        <spring.version> 4.24 .RELEASE </spring.version> 
        <hibernate.version> 5.07 .Final </hibernate.version> 
        <slf4j.version> 1.66 </slf4j.version> 
        <log4j.version> 1.212 </log4j.version> 
        <c3p0.version> 0.91.2 </c3p0.version> 
        <mysql.version> 5.16 </mysql.version> 
    </プロパティ> 

    <依存性> 
        <!
            <groupIdを> JUnitの</ groupIdを> 
            <たartifactId> JUnitの</たartifactId> 
            <バージョン> 4.9 </ version>の
            <スコープ>テスト</スコープ> 
        </依存関係> 
        
        <! -春BEG - > 
        <依存> 
            <groupIdを> org.aspectj </ groupIdを> 
            <たartifactId> aspectjweaver </たartifactId> 
            <バージョン> 1.68 </バージョン> 
        </依存> 

        <依存性> 
            <のgroupId> org.springframework </のgroupId> 
            <たartifactId>スプリングAOP </たartifactId>

        <依存性> 
            <のgroupId> org.springframework </のgroupId> 
            <たartifactId>ばねコンテキスト</たartifactId> 
            <バージョン> $ {spring.version} </バージョン> 
        </依存> 

        <依存性> 
            <のgroupId> org.springframework < /のgroupId> 
            <たartifactId>ばねコンテキストサポート</たartifactId> 
            <バージョン> $ {spring.version} </バージョン> 
        </依存> 

        <依存性> 
            <のgroupId> org.springframework </のgroupId> 
            <たartifactId> spring- ORM </たartifactId> 
            <バージョン> $ {spring.version} </バージョン>
        </依存関係> 
 
        <依存>
            <groupIdを> org.springframework </ groupIdを>
            <たartifactId>ばね豆</たartifactId> 
            <バージョン> $ {spring.version} </バージョン> 
        </依存> 

        <依存性> 
            <のgroupId> org.springframework </のgroupId> 
            <たartifactId>ばねコア</たartifactId> 
            <バージョン> $ {spring.version} </バージョン> 
        </依存関係> 
        
        <! -春の終わり- > 

        <! - BEGを休止状態- > 
        <依存> 
            <groupIdを> org.hibernate </ groupIdを> 
            <たartifactId >休止コア</たartifactId> 
            <バージョン> $ {hibernate.version} </バージョン> 
        </依存関係>  
        <依存性>
            <groupIdを> org.hibernate </ groupIdを> 
            <たartifactId>休止-のEntityManager </たartifactId> 
            <バージョン> $ {hibernate.version} </バージョン> 
        </依存> 
        <依存性> 
            <のgroupId> org.hibernate </のgroupId> 
            <たartifactId>休止状態-バリデータ</たartifactId> 
            <バージョン> 5.21 .Final </バージョン> 
        </依存関係> 
        <! -エンド休止状態- > 

        <! - C3P0 BEG - > 
        <依存> 
            <groupIdを> C3P0 </ groupIdを> 
            <たartifactId> C3P0 </たartifactId>
        <! - C3P0終わり- > 
        <依存>

        <依存性> 
            <のgroupId> log4jの</のgroupId> 
            <たartifactId> log4jの</たartifactId> 
            <バージョン> $ {log4j.version} </バージョン> 
        </依存> 

        <依存性> 
            <のgroupId> org.slf4j </のgroupId> 
            <たartifactId> SLF4J-API </たartifactId> 
            <バージョン> $ {slf4j.version} </バージョン> 
        </依存> 

        <依存性> 
            <のgroupId> org.slf4j </のgroupId> 
            <たartifactId> SLF4J-log4j12 </たartifactId> 
            <バージョン> $ {slf4j.version} </バージョン> 
        </依存>
        <! -最後のログを記録- >

        
            <のgroupId> MySQLの</のgroupId> 
            <たartifactId> MySQLのコネクタからJava </たartifactId> 
            <バージョン> $ {mysql.version} </バージョン> 
        </依存> 

        <依存性> 
            <のgroupId> org.springframework.data </ groupId> 
            <たartifactId>ばねデータJPA </たartifactId> 
            <バージョン> 1.90 .RELEASE </バージョン> 
        </依存> 

        <依存性> 
            <のgroupId> org.springframework </のgroupId> 
            <たartifactId>ばね試験</たartifactId> 
            <バージョン> 4.2
        
        <! -エルが使用春データを請うJPA必须引入- >
        <依存性>   
            <のgroupId> javax.el </のgroupId>   
            <たartifactId> javax.el-API </たartifactId>   
            <バージョン> 2.24 </バージョン>   
        </依存>   
          
        <依存性>   
            <のgroupId> org.glassfish.web </のgroupId>   
            <たartifactId> javax.el </たartifactId>   
            <バージョン> 2.24 </バージョン>   
        </依存関係> 
        <! -エルの終わり- > 
    </依存関係>

春2.統合春データJPA

1の<?xml version = "1.0"エンコード= "UTF-8"?>
 2 <豆のxmlns = "http://www.springframework.org/schema/beans"
 3つ      のxmlns:XSI = "のhttp:// WWW。 w3.org/2001/XMLSchema-instance」のxmlns:AOP = "http://www.springframework.org/schema/aop"
 4つ      のxmlns:コンテキスト= "http://www.springframework.org/schema/context"
 5      xmlns:JDBC = "http://www.springframework.org/schema/jdbc"のxmlns:TX = "http://www.springframework.org/schema/tx"
 6      のxmlns:JPA = "のhttp:// WWW。 springframework.org/schema/data/jpa "のxmlns:タスク= "http://www.springframework.org/schema/task"
 7      のxsi:schemaLocationの= "
8          のhttp:// www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd 
9          のhttp:// www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop .xsd 
10          のhttp:// www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
11          のhttp:// www.springframework.org/schema/jdbc HTTP ://www.springframework.org/schema/jdbc/spring-jdbc.xsd 
12          のhttp:// www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx。 XSD 
13          のhttp://www.springframework.org/schema/data/jpa 
14          のhttp:// www.springframework.org/schema/data/jpa/spring-jpa.xsd "> 
15      
16      <! - 1.dataSource配置数据库连接池- >
 17      <ビーンID = "データソース" クラス = "com.mchange.v2.c3p0.ComboPooledDataSource">
 18          <プロパティ名= "driverClass"値= "はcom.mysql.jdbc.Driver" />
 19          <プロパティ名=」 jdbcUrlと"値= "JDBC:MySQLの:// localhostを:3306 / JPA(数据库名)"/>
 20          <プロパティ名= "ユーザ"値= "ルート"/>
 21          <プロパティ名="パスワード"値=" 111111「(データベース・パスワード)/>
22      </ビーン>
 23      
24      <! - 2.配置のEntityManagerFactory - >
 25      <ビーンID = "のEntityManagerFactory" クラス = "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
 26          <プロパティ名= "データソース" REF = "データソース" />
 27          <プロパティ名= "packagesToScan"値=」cn.itcast.entity(包名 "/>
 28          <プロパティ名="はPersistenceProvider ">
 29              <ビーンクラス =" org.hibernate.jpa.HibernatePersistenceProvider "/>
 30          <
/プロパティ> 31です          !JPAのサプライヤーアダプタ- - > <
 32         <プロパティ名= "jpaVendorAdapter">
 33              <ビーンクラス = "org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
 34                  <プロパティ名= "generateDdl"値= "偽" />
 35                  <プロパティ名= "データベース"値= "MYSQL" />
 36                  <プロパティ名= "のDatabasePlatform"値= "org.hibernate.dialect.MySQLDialect" />
 37                  <プロパティ名= "SHOWSQL"値= "TRUE" />
 38              </ビーン>
 39          < /プロパティ>
 40          <
プロパティ名= "jpaDialect"> 41              <豆のクラス= "org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
 42          </プロパティ>
 43      </ビーン>
 44      
45      
46      <! - 3事务管理器- >
 47      <! - JPA事务管理器- >
 48      <豆ID = "のTransactionManager" クラス = "org.springframework.orm.jpa.JpaTransactionManager">
 49          <プロパティ名= "のEntityManagerFactory" REF = "のEntityManagerFactory" />
 50      </豆>
 51      
52      <! - -整合スプリングデータJPA - >
 53      <JPA:リポジトリ塩基パッケージ =」cn.itcast。DAO( 独自に構築パッケージ54         トランザクション・マネージャ-REF = "のTransactionManager"
 55          エンティティ・マネージャ・工場-REF = "のEntityManagerFactory"> </ JPA:リポジトリ>
 56          
57      <! - 4.txAdvice - >
 58      <TX:アドバイスID = "txAdvice"トランザクション・マネージャ= "のTransactionManager">
 59          <TX:属性>
 60              <TX:メソッド名= "保存*"伝播= "REQUIRED" />
 61              <TX:メソッド名= "挿入*"伝播= "REQUIRED" />
 62              <TX:メソッド名= "更新*"伝播= "REQUIRED" />
 63              <TX:メソッド名は= "削除*"
伝播= "REQUIRED" /> 64              <TX:メソッド名= "*を取得"読み取り専用= "真" />
 65             <TX:メソッド名= "見つける*"読み取り専用= "真" />
 66              <TX:メソッド名を= "*"伝播= "REQUIRED" />
 67          </ TX:属性>
 68      </ TX:アドバイス>
 69      
70      < - - 5.aop!>
 71      <AOP:config>の
 72          <AOP:ポイントカットのid = "ポイントカット"表現= "実行(。。* cn.itcast.service * *(..))" / >
 73          <AOP:アドバイザアドバイス-REF = "txAdvice"ポイントカット-REF = "ポイントカット" />
 74      </ AOP:設定>
 75      
76      <文脈:コンポーネントスキャン塩基のパッケージ =」cn.itcast(自分の書かれたパッケージ「> </コンテキスト:コンポーネントスキャン>
 77         
78      <! -組み立てその他のプロファイル- >
 79      
80 </ビーンズ>

すべての注釈は、JPAの仕様を提供するために使用されているので*、エンティティクラスのjavax.persisteceの使用は、注釈パケットを導入したとき

 

おすすめ

転載: www.cnblogs.com/threeboke/p/11281996.html