为了账号安全,请及时绑定邮箱和手机立即绑定

无法生成table,怎么回事

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

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://img1.sycdn.imooc.com//5e3bb9db00014ad518880573.jpg

正在回答

6 回答

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

0 回复 有任何疑惑可以回复我~
#1

码工1023

不出意外的话是配置问题,浪费大半天时间,差点放弃了
2020-04-12 回复 有任何疑惑可以回复我~

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

0 回复 有任何疑惑可以回复我~


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)


0 回复 有任何疑惑可以回复我~
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


0 回复 有任何疑惑可以回复我~

按照你的图片在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>


0 回复 有任何疑惑可以回复我~

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

2 新版本需要加上dialact

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

http://img1.sycdn.imooc.com//5e3e277b00014a1310401264.jpg

http://img1.sycdn.imooc.com//5e3e277b00018f5415280652.jpg


0 回复 有任何疑惑可以回复我~
#1

慕九州8576440 提问者

修改了下,还是没有启动对数据库相关的操作。不知道咋回事
2020-02-08 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

无法生成table,怎么回事

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信