2016-12-29 18 views
0

は、ストア・データベースに使用する私のdatabase.propertiesファイル
情報私はどのようにプロジェクトを高速化できますか?ここ

################### 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> 

私はMySQLデータベースを使用しています。私のデータベースのサイズは552 MBです。私は私のプロジェクトを実行すると5分以上かかります.100 MB以下の小さなデータベースを使用すると、速く動作します。プロジェクトを最初にどのように実行できますか?おかげさまで あなたは以下のようにひかり接続Pool.ReturnひかりのDataSource object.Sampleコードのために行くことができナシル

@

+1

この真剣にあなたの質問か?あなたはあなたのデータベースの設定を提供し、そのサイズを述べ、「プロジェクト」が遅いことに文句を言って、あなたはPrimeFacesでこの質問にタグをつけますか?そしてあなたのタイトルは「冬眠」だけが直接関係していると思われる「春の休止状態」を意味します。あなたはすでに19の評判ポイントを持っているので、私は100%あなたがもっとうまくいくことができると確信しています。私はあなたの質問を再タグ付けしています – Kukeltje

+0

Sir、データベース設定ファイルとデータベースサイズを追加しました –

答えて

0

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; 
} 
+0

戦争ファイルをエクスポートすると、データベースのURL、ユーザー名、パスワードを変更することはできません。私はエクスポートの戦争ファイルの後にデータベースのURL、ユーザー名とパスワードを変更する必要があります。 –

+0

私はあなたのデータベースの詳細を変更するつもりはありません....私は言いたいことは、あなたのデータソースの上に光の接続プーリングを使用することです... HikariConfig hc = new HikariConfig(props); HikariDataSource ds =新しいHikariDataSource(hc); –

+0

Sir私はHikariDataSourceを使うこともできますが、問題は解決しません。 –

関連する問題