Not must be hibernate.properties or hibernate.cfg.xml

阅读更多

     Sometimes, Custom have externalized the location of their property files to a location outside of the WARs, so their settings are not wiped out by code updates.  The problem is that we have a number of property files that share the same name.

     So that would like to propose that we adopt a unique naming construct for the following files:

* jdbc.properties
* log4j.properties
* hibernate.properties

     For each application, we should prefix each of these files with an identifier that creates a unique name so that the files can be located in the same directory without overlaying each other.  here are my suggestions for prefixing:

* applicationName-jdbc.properties

* applicationName-log4j.properties
* applicationName-hibernate.properties

    Step1:Modfiy Web.xml

    Old web.xml


		log4jConfigLocation
		classpath:log4j.properties
	

   New web.xml


		log4jConfigLocation
		classpath:applicationName-log4j.properties
	

    Step2:Modify applicationContext.xml

    Old applicationContext.xml


    



	

		

		
			
				
			
		

     New applicationContext.xml


    
    


	

		

		
			
				
			
		

        
        
            
                hibernate.dialect=${hibernate.dialect}
                
                hibernate.cache.provider_class=${hibernate.cache.provider_class}
                hibernate.cache.use_query_cache=${hibernate.cache.use_query_cache}
                hibernate.generate_statistics=${hibernate.generate_statistics}
                hibernate.show_sql=${hibernate.show_sql}
                hibernate.cache.use_structured_entries=${hibernate.cache.use_structured_entries}
            
        
        
	
 

    Additional hibernate.properties

## dialect
#hibernate.dialect =org.hibernate.dialect.OracleDialect
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
#hibernate.dialect = org.hibernate.dialect.SQLServerDialect

## cache
hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
hibernate.cache.use_query_cache=true
hibernate.cache.use_structured_entries=true

#hibernate.hbm2ddl.auto = update
hibernate.generate_statistics=true
hibernate.show_sql =false
 

你可能感兴趣的:(Hibernate,XML,JDBC,Cache,log4j)