2016-07-20 6 views
0

私は春と休止のためのmavenプロジェクトを持っており、私はすべてのステップと設定を行っています。休止状態の生成テーブルのエラー

1-私は 、3-が

を(DEF豆とコンフィグ用ファイル)は、アプリケーションのcontext.xmlを作成 2- persistence.xmlファイルを作成するエンティティを作成していますが、私は私のユニットテストを実行するときテーブルは私がkhnowいけ作成されない理由を

persistance.xmlの内容は次のとおりです。

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" 
    xmlns="http://java.sun.com/xml/ns/persistence" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
    http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd "> 
    <persistence-unit name="UP_BRI_SANTE" 
     transaction-type="RESOURCE_LOCAL"> 
     <provider>org.hibernate.ejb.HibernatePersistence</provider> 
     <properties> 
      <property name="hibernate.show_sql" value="true" /> 
      <property name="hibernate.hbm2dll.auto" value="update" /> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> 
     </properties> 
    </persistence-unit> 
</persistence> 

アプリケーション・コンテキストの内容は次のとおりです。

これは私のユニットテスト
<?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:tx="http://www.springframework.org/schema/tx" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> 



<!-- bean of data source --> 
    <bean id="datasource" 
     class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
     <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> 
     <property name="url" value="jdbc:mysql://localhost:3306/db_bri_sante"></property> 
     <property name="username" value="root"></property> 
     <property name="password" value=""></property> 
    </bean> 
    <!-- bean of persistence manager --> 
    <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"> 
     <property name="defaultDataSource" ref="datasource"></property> 
     <property name="persistenceXmlLocations"> 
      <list> 
       <value>classpath*:META-INF/persistence.xml</value> 
      </list> 
     </property> 
    </bean> 
    <!-- bean definition entityManagerFactory --> 
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
     <property name="persistenceUnitManager" ref="persistenceUnitManager"></property> 
     <property name="persistenceUnitName" value="UP_BRI_SANTE"></property> 
    </bean> 
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
     <property name="entityManagerFactory" ref="entityManagerFactory"></property> 
    </bean> 

    <tx:annotation-driven transaction-manager="transactionManager"/> 
    <context:annotation-config></context:annotation-config> 
    <context:component-scan base-package="com.bri.sante"></context:component-scan> 
</beans> 

私はあなたを助け必要と事前

+0

変更が 'create'、可能な値'に設定hibernate.hbm2dll.auto'とその使用方法は、ここで説明します。http ://stackoverflow.com/questions/18077327/hibernate-hbm2ddl-auto-possible-values-and-what-they-do-any-official-explanat – Lovababu

+0

私はhibernate.hbm2dll.auto(update 、create-drop)、それでもテーブルは作成されていない同じもの – user3578199

+0

ユニットテストを追加できますか? –

答えて

0

での感謝である

public class TestJPA { 

    @BeforeClass 
    public static void setUpBeforeClass() throws Exception { 
    } 

    @AfterClass 
    public static void tearDownAfterClass() throws Exception { 
    } 

    @Before 
    public void setUp() throws Exception { 
    } 

    @Test 
    public void test1() { 

     ClassPathXmlApplicationContext app= new ClassPathXmlApplicationContext(new String[]{"application-context.xml"}); 
     assertTrue(true); 

    } 

}