为啥我在数据库中,生成不了表格。这是我的部分代码
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
我的没有springbootapplication,依赖也都加了,还是没有生成表,啥情况啊 ??
解决了,我把这里注释掉,就可以了。。
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)
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
按照你的图片在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>
1 看一下pom的相关依赖,注意scope之类的没有写错或多写
2 新版本需要加上dialact
我发了截图,可以参考一下