Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

java - 如何修复Java异常“ SQLSyntaxErrorException:表'xy'不存在”(How to fix the Java exception “SQLSyntaxErrorException: Table 'x.y' doesn't exist”)

I am build an online shopping application.

(我正在构建一个在线购物应用程序。)

The application was working fine until I added payment model, payment resource, payment service, payment repository.

(在添加付款模型,付款资源,付款服务,付款存储库之前,该应用程序运行良好。)

I tried dropping the entire database after creating the payment model but still it did not work.

(创建付款模型后,我尝试删除整个数据库,但仍然无法正常工作。)

I don't know what seems to be a problem.

(我不知道这是什么问题。)


 .   ____          _            __ _ _
 /\ / ___'_ __ _ _(_)_ __  __ _    
( ( )\___ | '_ | '_| | '_ / _` |    
 \/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.2.RELEASE)

2019-11-28 08:48:46.797  INFO 6220 --- [           main] com.myshop.OnlineshoppingApplication     : Starting OnlineshoppingApplication on BooTCamp1 with PID 6220 (C:UsersReversideDocuments
eversidefinalworkprojectonlineshoppingargetclasses started by Reverside in C:UsersReversideDocuments
eversidefinalworkprojectonlineshopping)
2019-11-28 08:48:46.800  INFO 6220 --- [           main] com.myshop.OnlineshoppingApplication     : No active profile set, falling back to default profiles: default
2019-11-28 08:48:48.099  INFO 6220 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3ee0fea4: startup date [Thu Nov 28 08:48:48 CAT 2019]; root of context hierarchy
2019-11-28 08:48:49.256  INFO 6220 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-11-28 08:48:49.387  INFO 6220 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2019-11-28 08:48:49.483  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.UserRepository.
2019-11-28 08:48:49.484  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.CartItemRepository.
2019-11-28 08:48:49.484  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.ProductToCartItemRepository.
2019-11-28 08:48:49.484  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.DeliveryAddressRepository.
2019-11-28 08:48:49.485  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.UserBillingRepository.
2019-11-28 08:48:49.485  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.UserPaymentRepository.
2019-11-28 08:48:49.485  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.OrderRepository.
2019-11-28 08:48:49.485  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.UserDeliveryRepository.
2019-11-28 08:48:49.486  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.RoleRepository.
2019-11-28 08:48:49.486  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.ProductRepository.
2019-11-28 08:48:49.486  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.ShoppingCartRepository.
2019-11-28 08:48:49.487  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.BillingAddressRepository.
2019-11-28 08:48:49.487  INFO 6220 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.myshop.repository.PaymentRepository.
2019-11-28 08:48:49.997  INFO 6220 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$7d6e0f9b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-11-28 08:48:50.587  INFO 6220 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2019-11-28 08:48:50.613  INFO 6220 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2019-11-28 08:48:50.615  INFO 6220 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.11
2019-11-28 08:48:50.998  INFO 6220 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-11-28 08:48:50.999  INFO 6220 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2912 ms
2019-11-28 08:48:51.151  INFO 6220 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-11-28 08:48:51.163  INFO 6220 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-11-28 08:48:51.163  INFO 6220 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-11-28 08:48:51.163  INFO 6220 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-11-28 08:48:51.164  INFO 6220 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2019-11-28 08:48:51.164  INFO 6220 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2019-11-28 08:48:52.006  INFO 6220 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-11-28 08:48:52.029  INFO 6220 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
2019-11-28 08:48:52.251  INFO 6220 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.0.12.Final}
2019-11-28 08:48:52.253  INFO 6220 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2019-11-28 08:48:52.265  INFO 6220 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2019-11-28 08:48:52.482  INFO 6220 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2019-11-28 08:48:52.784  INFO 6220 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2019-11-28 08:48:54.230  INFO 6220 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000228: Running hbm2ddl schema update
2019-11-28 08:48:54.383  INFO 6220 --- [           main] rmationExtractorJdbcDatabaseMetaDataImpl : HHH000262: Table not found: payment
2019-11-28 08:48:54.556  WARN 6220 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2019-11-28 08:48:54.566  INFO 6220 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2019-11-28 08:48:54.581  WARN 6220 --- [           main] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)
2019-11-28 08:48:54.588 ERROR 6220 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.context.support.Abstract

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your error clearly pointed that you have not created database table : shopdb.payment .

(您的错误明确指出您尚未创建数据库表: shopdb.payment 。)

And because of that your persistence flow getting break(Error : creating bean with entity manager relate with that).

(由于这个原因,您的持久流将中断(错误:使用实体管理器创建bean与此相关)。)

If you don't want to put any configuration for auto generate table then create manually but if you do that dynamically then,

(如果您不想为自动生成表添加任何配置,则可以手动创建,但如果您动态地进行配置,)

There is several reasons for database table not created at run time:

(在运行时未创建数据库表的原因有很多:)

  1. AutoConfiguration aren't work properly.

    (自动配置无法正常工作。)

    Add annotation(Given Or other provided by spring),

    (添加批注(Given或spring提供的其他),)

@EnableAutoConfiguration

(@EnableAutoConfiguration)

@PropertySource

(@PropertySource)

@EntityScan

(@EntityScan)

  1. Database configuration and auto creation statement not properly placed in application.configuration / application.yml file.

    (数据库配置和自动创建语句未正确放置在application.configuration / application.yml文件中。)

spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

(spring.jpa.database-platform = org.hibernate.dialect.MySQL5InnoDBDialect)

spring.jpa.generate-ddl=true

(spring.jpa.generate-ddl = true)

spring.jpa.hibernate.ddl-auto=create

(spring.jpa.hibernate.ddl-auto =创建)

spring.datasource.driverClassName=com.mysql.jdbc.Driver

(spring.datasource.driverClassName = com.mysql.jdbc.Driver)

spring.datasource.url=jdbc:mysql://localhost:3306/shopdb

(spring.datasource.url = jdbc:mysql:// localhost:3306 / shopdb)

spring.datasource.username=database_username

(spring.datasource.username =数据库用户名)

spring.datasource.password=database_password

(spring.datasource.password =数据库密码)

  1. Here some case you need to create default schema of your database.

    (在某些情况下,您需要创建数据库的默认架构。)

  2. In some situation case sensitivity create ideal role when you do this kind of activity,

    (在某些情况下,当您进行此类活动时,敏感性会发挥理想的作用,)

    • I highly recommended that define @Table, @Column annotation or Lombok kind of library(If supportable to your version).

      (我强烈建议定义@ Table,@ Column批注或Lombok类的库(如果您的版本支持)。)

    • Check your column name as per your requirement(Not related with error).

      (根据您的要求检查列名(与错误无关)。)

  3. Also verify your mapping is exist, place and work properly with private context.

    (还要验证您的映射是否存在,并在私有上下文中正确放置和使用。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...