必要なプロファイル(applicationContext.xmlを)とjdbc.propertiesを開発するためにSSM DAO層のフレームワークを使用してください。

一、applicationContext.xmlを
<xmlのバージョン= "1.0"エンコード= "UTF-8"?> 
<豆のxmlns = "http://www.springframework.org/schema/beans" 
       のxmlns:XSI = "のhttp:// www.w3.org/2001/XMLSchema-instance " 
       のxmlns:コンテキスト= "http://www.springframework.org/schema/context" 
       のxsi:schemaLocationの=" http://www.springframework.org/schema/beansのhttp ://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd "> 
        < -扫描包- >!
        <コンテキスト:コンポーネント・スキャンベースパッケージ=" cn.kgc.dao "> </コンテキスト:コンポーネント・スキャン> 
        <! -引入外部配置文件- >
        <コンテキスト:プロパティプレースホルダ位置= "クラスパス:jdbc.properties"> </コンテキスト:プロパティのプレースホルダ> CLASSPATH:jdbc.properties「> </コンテキスト:不動産-プレースホルダ> 
        < - > -データソースを作成します!
        <ビーンID = "データソース"クラス= "com.mchange.v2.c3p0.ComboPooledDataSource"> 
            <プロパティ名=」 driverClass "値= "$ {jdbc.driver}"> </ property>の
            <プロパティ名= "jdbcUrlと"値= "$ {jdbc.url}"> </ property>の
            <プロパティ名= "ユーザ"値=" $ {jdbc.user} "> </ property>の
            <プロパティ名="パスワード」値= "$ {jdbc.password}"> </ property>の
        </ビーン> 
</豆> 

二、jdbc.properties 
jdbc.driver = com.mysql.jdbc。ドライバー
jdbc.url = JDBCます。mysql:// localhostを:3306 / group_project 
jdbc.user =ルート
jdbc.password = ROOT

  

おすすめ

転載: www.cnblogs.com/Hubert-dzl/p/11456964.html