私はspringbootプロジェクトでMySQLデータベースを生成したいと思います。 私はMavenプロジェクトを作成し、これはのpom.xmlです:springbootでMySqlデータベースを生成
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Springboot</groupId>
<artifactId>ma.mahmoud.springboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SpringBootApps</name>
<description>First project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.4.RELEASE</version>
</parent>
<properties>
<hibernate.version>5.0.3.Final</hibernate.version>
<spring.version>4.2.2.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- SPRING -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
<!-- BUILD -->
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
私はのjavax.persistenceアノテーションでエンティティを作成し、私は春のデータとDAO、サービスおよび公開するためのコントローラを作成します私のサービス。
私は自分のアプリケーションを起動すると、私はすべてのエラーを持っていないが、データベースが作成されたNITでのsrc /メイン/リソース
server.port=1111
spring.datasource.url=jdbc:mysql://localhost:3306/sping-boot
spring.datasource.username=root
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=create-drop
でapplication.propertiesを追加します。
私は何かを忘れましたか?
[春ブーツが自動的にデータベーススキーマを作成するために取得できません]の可能な重複(http://stackoverflow.com/questions/26881739/unable-to -get-spring-boot-to-automatically-create-database-schema) – Patrick
私はあなたが正しいと思います。 私はメインクラスとエンティティを別々のパッケージにしていますが、私はツリーを尊重していません。この曲がうまくいけば私はあなたに伝えます。 – Mahmoud
'spring.jpa.hibernate.ddl-auto = create-drop'は、アプリケーションがシャットダウンした後にテーブルを削除します。 – Sergio