Retrieve MySpringdataSource from the configuration file

Source: Internet
Author: User
This article is a personal note. The original database configuration file is written to death. Code: Mybatis configuration file beanid=ceclassorg. apache. commons. dbcp. basicperformancepropertynamedriverclassnamevaluecom. mysql. jdbc. Drivervaluepropertypropertynameu

This article is a personal note. The original database configuration file is written to death. Code: Mybatis configuration file bean id = dataSource class = org. apache. commons. dbcp. BasicDataSourceproperty name = driverClassNamevaluecom. mysql. jdbc. Driver/value/propertyproperty name = u

This article is a personal note.

The original database configuration file is written to death.

Code: Mybatis configuration file

 
  
   
    
Com. mysql. jdbc. Driver
   
  
  
   
    
Jdbc: mysql: // localhost: 3306/test
      
  
  
   
    
Root
   
  
  
   
    
Admin
    
  
 
 
 
  
  
 
 
 
  
 
The username and password here are all dead. Now I want a special configuration file to configure the database.

Baidu is easy.

Add the path of the data source configuration file and modify the database configuration.

 
         
           
            
            
            
        
 WEB-INF \ config \ project. properties file:
database.ip =127.0.0.1database.port =3306database.userName =rootdatabase.passWord =admin
Change to driverClassName, url, username, and password. For personal project reasons, database port configuration is required in other places, so the url is spliced.

Note:

   

Here classpath: path refers to the WEB-INF/classes

Also designed. The difference between BasicDataSource DriverManagerDataSource is not ugly here.

Spring DriverManagerDataSource and apache BasicDataSource ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.