Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我想使用springboot和hibernate创建一个表,虽然没有错误,但表可以';不能创造,为什么?_Java_Spring_Hibernate_Maven_Spring Boot - Fatal编程技术网

Java 我想使用springboot和hibernate创建一个表,虽然没有错误,但表可以';不能创造,为什么?

Java 我想使用springboot和hibernate创建一个表,虽然没有错误,但表可以';不能创造,为什么?,java,spring,hibernate,maven,spring-boot,Java,Spring,Hibernate,Maven,Spring Boot,下面是应用程序属性: server.port=8080 spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html spring.thymeleaf.mode=LEGACYHTML5 spring.thymeleaf.encoding=UTF-8 spring.thymeleaf.content-type=text/html spring.thymeleaf.cache=false spring.dat

下面是
应用程序属性

server.port=8080
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false

spring.datasource.url=jdbc:mysql://127.0.0.1/springboot?characterEncoding=UTF-8&autoReconnect=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driverClassName=com.mysql.jdbc.Driver

spring.datasource.max-active=5
spring.datasource.max-idle=2
spring.datasource.min-idle=1
spring.datasource.initial-size=1
spring.datasource.initialize=false
spring.datasource.test-on-borrow=false
spring.datasource.test-on-return=false
spring.datasource.test-while-idle=true
#spring.datasource.max-wait-millis=30000
spring.datasource.validation-query=SELECT 1
spring.datasource.time-between-eviction-runs-millis=20000
spring.datasource.min-evictable-idle-time-millis=28700

# Specify the DBMS
spring.jpa.database = MYSQL
# Hibernate ddl auto (create, create-drop, update)
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
下面是我认为正确的
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.3.7.Final</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

4.0.0
com.example
演示
0.0.1-快照
罐子
演示
SpringBoot的演示项目
org.springframework.boot
spring启动程序父级
1.3.3.1发布
UTF-8
UTF-8
1.8
org.springframework.boot
弹簧启动机aop
org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
弹簧靴启动器jdbc
org.springframework.session
春季会议
org.springframework.boot
弹簧启动装置
org.springframework.boot
SpringBootStarterWeb
org.hibernate
冬眠核心
4.3.7.最终版本
mysql
mysql连接器java
运行时
org.springframework.boot
弹簧起动试验
测验
org.springframework.boot
springbootmaven插件
但当我运行它时,控制台会显示:

2017-03-03 13:16:57.999信息29616---[main]org.hibernate.Version:hh000412:hibernate核心{4.3.7.Final}
2017-03-03 13:16:58.001信息29616---[main]org.hibernate.cfg.Environment:hh000206:hibernate.properties未找到
2017-03-03 13:16:58.003信息29616---[main]org.hibernate.cfg.Environment:hh000021:字节码提供程序名称:javassist


另一个什么都不是。但是表不能创建。

spring.jpa.hibernate.ddl auto=update
更改为
spring.jpa.hibernate.ddl auto=create
…注意spring.jpa.hibernate.ddl-auto不应该在prod中使用。

我遇到了同样的问题,我通过将h2控制台的实际路径复制到
spring.datasource.url=”“

application.properties

中,从
pom.xml
中删除
hibernate核心
依赖项,通过
spring boot starter数据jpa对其进行过渡式管理
好的,我会尝试。