maven-spring-boot试图连接到mysql

bogh5gae  于 2021-06-29  发布在  Java
关注(0)|答案(3)|浏览(565)

我正在尝试将我的web应用程序连接到mysql。spring boot没有检测到数据库,但是可以连接到服务器。有没有人能把我引向正确的方向,这样它就能检测出模式。使用@entity注解,它应该在数据库中自动创建一个表作为“user”。它还应该说,在控制台“数据库可用”,我曾试图寻找网上,但没有结果。任何帮助都将不胜感激!

这是我的application.properties

  1. spring.datasource.url=jdbc:mysql://localhost:3306/espersdb
  2. spring.datasource.username=root
  3. spring.datasource.password=password
  4. spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  5. spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
  6. spring.jpa.hibernate.ddl-auto=none

这是我的控制台

  1. 2020-12-27 03:32:47.859 INFO 26012 --- [ restartedMain] c.D.E.E.EspersWebsiteApplication : Starting EspersWebsiteApplication using Java 14.0.2 on DESKTOP-01JT4QR with PID 26012 (C:\Users\Donobuz\Documents\Espers_Website\target\classes started by Donobuz in C:\Users\Donobuz\Documents\Espers_Website)
  2. 2020-12-27 03:32:47.862 INFO 26012 --- [ restartedMain] c.D.E.E.EspersWebsiteApplication : No active profile set, falling back to default profiles: default
  3. 2020-12-27 03:32:47.913 INFO 26012 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
  4. 2020-12-27 03:32:47.913 INFO 26012 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
  5. 2020-12-27 03:32:48.510 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
  6. 2020-12-27 03:32:48.511 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JDBC repositories in DEFAULT mode.
  7. 2020-12-27 03:32:48.516 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 3 ms. Found 0 JDBC repository interfaces.
  8. 2020-12-27 03:32:48.523 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
  9. 2020-12-27 03:32:48.523 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
  10. 2020-12-27 03:32:48.529 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 0 ms. Found 0 JPA repository interfaces.
  11. 2020-12-27 03:32:48.830 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  12. 2020-12-27 03:32:48.833 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'relProviderPluginRegistry' of type [org.springframework.plugin.core.support.PluginRegistryFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  13. 2020-12-27 03:32:48.839 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'relProviderPluginRegistry' of type [org.springframework.plugin.core.OrderAwarePluginRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  14. 2020-12-27 03:32:48.842 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean '_relProvider' of type [org.springframework.hateoas.server.core.DelegatingLinkRelationProvider] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  15. 2020-12-27 03:32:48.847 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'messageResolver' of type [org.springframework.hateoas.mediatype.MessageSourceResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  16. 2020-12-27 03:32:48.848 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.data.web.config.SpringDataJacksonConfiguration' of type [org.springframework.data.web.config.SpringDataJacksonConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  17. 2020-12-27 03:32:48.851 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonGeoModule' of type [org.springframework.data.geo.GeoModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  18. 2020-12-27 03:32:48.861 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration' of type [org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  19. 2020-12-27 03:32:48.863 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  20. 2020-12-27 03:32:48.864 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  21. 2020-12-27 03:32:48.872 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties' of type [org.springframework.boot.autoconfigure.jackson.JacksonProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  22. 2020-12-27 03:32:48.873 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'standardJacksonObjectMapperBuilderCustomizer' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration$StandardJackson2ObjectMapperBuilderCustomizer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  23. 2020-12-27 03:32:48.875 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$ParameterNamesModuleConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$ParameterNamesModuleConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  24. 2020-12-27 03:32:48.876 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'parameterNamesModule' of type [com.fasterxml.jackson.module.paramnames.ParameterNamesModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  25. 2020-12-27 03:32:48.877 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  26. 2020-12-27 03:32:48.881 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jsonComponentModule' of type [org.springframework.boot.jackson.JsonComponentModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  27. 2020-12-27 03:32:48.883 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapperBuilder' of type [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  28. 2020-12-27 03:32:48.888 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.data.rest-org.springframework.boot.autoconfigure.data.rest.RepositoryRestProperties' of type [org.springframework.boot.autoconfigure.data.rest.RepositoryRestProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  29. 2020-12-27 03:32:48.889 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'springBootRepositoryRestConfigurer' of type [org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestConfigurer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  30. 2020-12-27 03:32:48.890 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'configurerDelegate' of type [org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerDelegate] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  31. 2020-12-27 03:32:48.896 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration' of type [org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  32. 2020-12-27 03:32:48.902 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'stringHttpMessageConverter' of type [org.springframework.http.converter.StringHttpMessageConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  33. 2020-12-27 03:32:48.903 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration' of type [org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  34. 2020-12-27 03:32:48.903 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  35. 2020-12-27 03:32:48.907 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapperBuilder' of type [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  36. 2020-12-27 03:32:48.929 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapper' of type [com.fasterxml.jackson.databind.ObjectMapper] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  37. 2020-12-27 03:32:48.934 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'mappingJackson2HttpMessageConverter' of type [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  38. 2020-12-27 03:32:48.935 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration' of type [org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
  39. 2020-12-27 03:32:49.190 INFO 26012 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
  40. 2020-12-27 03:32:49.197 INFO 26012 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
  41. 2020-12-27 03:32:49.197 INFO 26012 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
  42. 2020-12-27 03:32:49.278 INFO 26012 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  43. 2020-12-27 03:32:49.279 INFO 26012 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1364 ms
  44. 2020-12-27 03:32:49.512 INFO 26012 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
  45. 2020-12-27 03:32:49.546 INFO 26012 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.25.Final
  46. 2020-12-27 03:32:49.620 INFO 26012 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
  47. 2020-12-27 03:32:49.682 INFO 26012 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
  48. 2020-12-27 03:32:49.924 INFO 26012 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
  49. 2020-12-27 03:32:49.933 INFO 26012 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
  50. 2020-12-27 03:32:50.049 INFO 26012 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
  51. 2020-12-27 03:32:50.056 INFO 26012 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  52. 2020-12-27 03:32:50.135 WARN 26012 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
  53. 2020-12-27 03:32:50.374 INFO 26012 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
  54. 2020-12-27 03:32:50.954 INFO 26012 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6707114e, org.springframework.security.web.context.SecurityContextPersistenceFilter@20e3d55, org.springframework.security.web.header.HeaderWriterFilter@10647f40, org.springframework.security.web.csrf.CsrfFilter@17135eb0, org.springframework.security.web.authentication.logout.LogoutFilter@297f9882, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@21beac54, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@2741bf4a, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@425f1341, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@5e42e0a, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@7df3f08, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@51e53a6e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@666fe17e, org.springframework.security.web.session.SessionManagementFilter@46a96507, org.springframework.security.web.access.ExceptionTranslationFilter@7edc01a5, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@460056c3]
  55. 2020-12-27 03:32:51.017 INFO 26012 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 8081
  56. 2020-12-27 03:32:51.050 INFO 26012 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
  57. 2020-12-27 03:32:51.059 INFO 26012 --- [ restartedMain] c.D.E.E.EspersWebsiteApplication : Started EspersWebsiteApplication in 3.585 seconds (JVM running for 4.305)
  58. 2020-12-27 03:33:11.148 INFO 26012 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
  59. 2020-12-27 03:33:11.149 INFO 26012 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
  60. 2020-12-27 03:33:11.151 INFO 26012 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms

这是我的dto/实体

  1. package entities;
  2. import lombok.AllArgsConstructor;
  3. import lombok.Data;
  4. import lombok.NoArgsConstructor;
  5. import javax.persistence.Entity;
  6. import javax.persistence.GeneratedValue;
  7. import static javax.persistence.GenerationType.IDENTITY;
  8. import javax.persistence.Id;
  9. import javax.validation.constraints.Email;
  10. import java.time.Instant;
  11. @Entity
  12. @Data
  13. @NoArgsConstructor
  14. @AllArgsConstructor
  15. public class User {
  16. @Id
  17. @GeneratedValue(strategy = IDENTITY)
  18. private Long userID;
  19. private String username;
  20. private String password;
  21. @Email
  22. private String email;
  23. private Instant createdDate;
  24. private boolean enabled;
  25. }

我的用户存储库

  1. package repos;
  2. import entities.User;
  3. import org.springframework.data.repository.CrudRepository;
  4. public interface UserRepository extends CrudRepository<User, Long> {
  5. }

最后,这是我的pom.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>2.4.1</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>com.Donobuz.Espers</groupId>
  12. <artifactId>Espers_Website</artifactId>
  13. <version>0.0.1-SNAPSHOT</version>
  14. <name>Espers_Website</name>
  15. <description>A web application with many features to help gamers</description>
  16. <properties>
  17. <java.version>11</java.version>
  18. </properties>
  19. <dependencies>
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-data-jdbc</artifactId>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-data-jpa</artifactId>
  27. </dependency>
  28. <dependency>
  29. <groupId>org.springframework.boot</groupId>
  30. <artifactId>spring-boot-starter-data-rest</artifactId>
  31. </dependency>
  32. <dependency>
  33. <groupId>org.springframework.boot</groupId>
  34. <artifactId>spring-boot-starter-jdbc</artifactId>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.springframework.boot</groupId>
  38. <artifactId>spring-boot-starter-mail</artifactId>
  39. </dependency>
  40. <dependency>
  41. <groupId>org.springframework.boot</groupId>
  42. <artifactId>spring-boot-starter-security</artifactId>
  43. </dependency>
  44. <dependency>
  45. <groupId>org.springframework.boot</groupId>
  46. <artifactId>spring-boot-starter-web</artifactId>
  47. </dependency>
  48. <dependency>
  49. <groupId>org.springframework.boot</groupId>
  50. <artifactId>spring-boot-devtools</artifactId>
  51. <scope>runtime</scope>
  52. <optional>true</optional>
  53. </dependency>
  54. <dependency>
  55. <groupId>org.projectlombok</groupId>
  56. <artifactId>lombok</artifactId>
  57. <optional>true</optional>
  58. </dependency>
  59. <dependency>
  60. <groupId>org.springframework.boot</groupId>
  61. <artifactId>spring-boot-starter-test</artifactId>
  62. <scope>test</scope>
  63. </dependency>
  64. <dependency>
  65. <groupId>org.springframework.security</groupId>
  66. <artifactId>spring-security-test</artifactId>
  67. <scope>test</scope>
  68. </dependency>
  69. <dependency>
  70. <groupId>jakarta.validation</groupId>
  71. <artifactId>jakarta.validation-api</artifactId>
  72. <version>2.0.2</version>
  73. </dependency>
  74. <dependency>
  75. <groupId>mysql</groupId>
  76. <artifactId>mysql-connector-java</artifactId>
  77. <version>8.0.22</version>
  78. </dependency>
  79. </dependencies>
  80. <build>
  81. <plugins>
  82. <plugin>
  83. <groupId>org.springframework.boot</groupId>
  84. <artifactId>spring-boot-maven-plugin</artifactId>
  85. <configuration>
  86. <excludes>
  87. <exclude>
  88. <groupId>org.projectlombok</groupId>
  89. <artifactId>lombok</artifactId>
  90. </exclude>
  91. </excludes>
  92. </configuration>
  93. </plugin>
  94. </plugins>
  95. </build>
  96. </project>
fwzugrvs

fwzugrvs1#

试试这个 spring.jpa.hibernate.ddl-auto=update

t1qtbnec

t1qtbnec2#

我已经想出了答案:我必须申报 spring.jpa.generate-ddl=true 在应用程序属性中也是如此。这样就可以用正确的列正确地创建指定的表

hmtdttj4

hmtdttj43#

请在url中附加一些属性(如果要自动生成数据库)

  1. spring.datasource.url=jdbc:mysql://localhost:3306/espersdb?createDatabaseIfNotExist=true
  2. spring.jpa.hibernate.ddl-auto=update
  3. @Entity
  4. @Data
  5. @NoArgsConstructor
  6. @AllArgsConstructor
  7. @Table(name="User") // missing in your code
  8. public class User {
  9. //blah blah
  10. }

相关问题