Spring 如何快速运行我的项目?
这是我的database.properties文件,用于存储数据库Spring 如何快速运行我的项目?,spring,hibernate,spring-data-jpa,Spring,Hibernate,Spring Data Jpa,这是我的database.properties文件,用于存储数据库 信息 ################### JDBC Configuration ########################## jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/eduman_em? verifyServerCertificate=false&useSSL=false&requ
信息
################### JDBC Configuration ##########################
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/eduman_em?
verifyServerCertificate=false&useSSL=false&requireSSL=false
jdbc.username=root
jdbc.password=1234
########## Hibernate Configuration #########
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
#### hibernate.show_sql=true
#### hibernate.hbm2ddl.auto=update
#### hibernate.generate_statistics=true
hibernate.connection.charSet=UTF-8
hibernate.ejb.naming_
strategy=org.hibernate.cfg.ImprovedNamingStrategy
hibernate.cache.provider_class=
org.hibernate.cache.HashtableCacheProvider
################## For List insertion Hiber Config
###hibernate.order_inserts=true###
####hibernate.order_updates=true####
This is my **applicationContext-db.xml**
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
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-4.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<!-- Scan for property files -->
<context:property-placeholder location="classpath:META-INF/spring/*.properties"/>
<!-- Transaction Manager -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
<!-- Detect @Transactional -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- Entity Manager Factory -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<!-- Define Hibernate JPA Vendor Adapter -->
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<!-- <property name="generateDdl" value="true" /> -->
<property name="database" value="MYSQL" />
</bean>
</property>
<!-- Persistence Unit -->
<property name="persistenceUnitName" value="persistenceUnit"/>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
p:username="${jdbc.username}" p:password="${jdbc.password}" />
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
JDBC配置##########################
jdbc.drivercassname=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/eduman_em?
verifyServerCertificate=false&useSSL=false&requireSSL=false
username=root
密码=1234
##########休眠配置#########
hibernate.dialogue=org.hibernate.dialogue.mysql5innodbdialogue
####hibernate.show_sql=true
####hibernate.hbm2ddl.auto=更新
####hibernate.generate_statistics=true
hibernate.connection.charSet=UTF-8
hibernate.ejb.naming_
strategy=org.hibernate.cfg.ImprovedNamingStrategy
hibernate.cache.provider\u类=
org.hibernate.cache.HashtableCacheProvider
##################用于列表插入Hiber配置
###hibernate.order_inserts=true###
####hibernate.order\u updates=true####
这是我的**applicationContext-db.xml**
我使用mysql数据库。我的数据库大小为552MB。当我运行我的项目时,它需要超过5分钟。如果我使用100 MB以下/小型数据库,那么它运行得很快。如何首先运行我的项目。
谢谢。@Nasir
您可以转到Hikari连接池。返回Hikari数据源对象。示例代码如下:
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
@Bean
public DataSource dataSource() {
// In classpath from spring-boot-starter-web
final Properties props = new Properties();
props.put("driverClassName", "com.mysql.jdbc.Driver");
props.put("jdbcUrl", "jdbc:mysql://localhost:3306/master?createDatabaseIfNotExist=false");
props.put("username", "root");
props.put("password", "mysql");
HikariConfig hc = new HikariConfig(props);
HikariDataSource ds = new HikariDataSource(hc);
return ds;
}
这真的是你的问题吗?你提供了你的数据库配置,说明了它的大小,抱怨“项目”太慢,你在这个问题上的标签是PrimeFaces吗?你的标题“just”是“spring hibernate jpa”,其中只有“hibernate”看起来是直接相关的。因为你已经有19个声誉点,我100%相信你可以做得更好,我正在重新记录你的问题先生,我添加了数据库配置文件和数据库大小,我不能使用这个类,因为当我导出war文件时,我不能更改数据库url、用户名和密码。导出war文件后,我需要更改数据库url、用户名和密码。我不是说要更改您的数据库详细信息…我的意思是在您的数据源上使用Hikari连接池。。。HikariConfig hc=新HikariConfig(道具);HikariDataSource ds=新的HikariDataSource(hc);先生,我也可以使用HikariDataSource,但无法解决问题。