无法生成table,怎么回事

来源:6-1 关于红包收发之操作数据库(上)

慕九州8576440

2020-02-06 15:03

为啥我在数据库中,生成不了表格。这是我的部分代码

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/luckymoney?serverTimezone=GMT
    username: root
    password: g
  jpa:
    hibernate:
      ddl-auto: create
    show-sql: true

http://img.mukewang.com/5e3bb9db00014ad518880573.jpg

写回答 关注

6回答

  • 幕布斯2086453
    2020-03-25 09:40:27

    我的没有springbootapplication,依赖也都加了,还是没有生成表,啥情况啊  ??

    码工1023

    不出意外的话是配置问题,浪费大半天时间,差点放弃了

    2020-04-12 13:35:33

    共 1 条回复 >

  • 慕九州8576440
    2020-02-08 14:45:46

    解决了,我把这里注释掉,就可以了。。
    http://img1.mukewang.com/5e3e59180001ee9611420659.jpg

  • 慕九州8576440
    2020-02-08 12:07:24


    2020-02-08 12:00:45.558  INFO 10808 --- [           main] c.i.luckymoney.LuckymoneyApplication     : Starting LuckymoneyApplication on v_rslv-NB2 with PID 10808 (D:\softwore\Idea\Project\luckymoney\target\classes started by v_rslv in D:\softwore\Idea\Project\luckymoney)

    2020-02-08 12:00:45.561  INFO 10808 --- [           main] c.i.luckymoney.LuckymoneyApplication     : The following profiles are active: dev

    2020-02-08 12:00:46.537  INFO 10808 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)

    2020-02-08 12:00:46.552  INFO 10808 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

    2020-02-08 12:00:46.552  INFO 10808 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.16]

    2020-02-08 12:00:46.556  INFO 10808 --- [           main] o.a.catalina.core.AprLifecycleListener   : Loaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.6.5].

    2020-02-08 12:00:46.556  INFO 10808 --- [           main] o.a.catalina.core.AprLifecycleListener   : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].

    2020-02-08 12:00:46.556  INFO 10808 --- [           main] o.a.catalina.core.AprLifecycleListener   : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]

    2020-02-08 12:00:46.559  INFO 10808 --- [           main] o.a.catalina.core.AprLifecycleListener   : OpenSSL successfully initialized [OpenSSL 1.1.1a  20 Nov 2018]

    2020-02-08 12:00:46.690  INFO 10808 --- [           main] o.a.c.c.C.[.[localhost].[/luckymoney]    : Initializing Spring embedded WebApplicationContext

    2020-02-08 12:00:46.690  INFO 10808 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1089 ms

    2020-02-08 12:00:46.859  INFO 10808 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'

    2020-02-08 12:00:47.012  INFO 10808 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path '/luckymoney'

    2020-02-08 12:00:47.014  INFO 10808 --- [           main] c.i.luckymoney.LuckymoneyApplication     : Started LuckymoneyApplication in 1.876 seconds (JVM running for 2.768)


  • 慕九州8576440
    2020-02-08 12:06:49
    spring:
      datasource:
        driver-class-name: com.mysql.cj.jdbc.Driver
        url: jdbc:mysql://127.0.0.1:3306/luckymoney?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
        username: root
        password: lv
      jpa:
        hibernate:
          ddl-auto: create
        show-sql: true
        properties:
          hibernate:
            dialect: org.hibernate.dialect.MySQL5InnoDBDialect


  • 慕九州8576440
    2020-02-08 12:04:44

    按照你的图片在pom中增加了依赖,也加上了dialect。但是还是没有对数据库进行操作。

       <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
                <scope>test</scope>
            </dependency>
    
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</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-data-jpa</artifactId>
            </dependency>
    
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-commons</artifactId>
                <version>2.1.5.RELEASE</version>
            </dependency>
    
        </dependencies>


  • Jupiters
    2020-02-08 11:14:08

    1 看一下pom的相关依赖,注意scope之类的没有写错或多写

    2 新版本需要加上dialact

    我发了截图,可以参考一下

    http://img.mukewang.com/5e3e277b00014a1310401264.jpg

    http://img2.mukewang.com/5e3e277b00018f5415280652.jpg


    慕九州857...

    修改了下,还是没有启动对数据库相关的操作。不知道咋回事

    2020-02-08 12:08:13

    共 1 条回复 >

2小时上手SpringBoot

2小时上手SpringBoot,实战开发红包表白程序,体现程序员专属花式浪漫

11882 学习 · 115 问题

查看课程

相似问题