运行SpringBootApplication
时出现以下错误:
2016-04-23 05:50:24.346 INFO 11585 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2016-04-23 05:50:24.356 INFO 11585 --- [ restartedMain] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2016-04-23 05:50:24.385 INFO 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2016-04-23 05:50:24.405 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table comment drop foreign key FK_i2t738wo4x3tdcmbhqgomubmg
2016-04-23 05:50:24.405 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.comment' doesn't exist
2016-04-23 05:50:24.423 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table comment drop foreign key FK_t0dkmpiim1vamsp4gk8prew3n
2016-04-23 05:50:24.423 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.comment' doesn't exist
2016-04-23 05:50:24.441 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table course drop foreign key FK_cuaoq0uw55jpcfvfhbuii5utp
2016-04-23 05:50:24.441 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.course' doesn't exist
2016-04-23 05:50:24.461 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table course_material drop foreign key FK_bs5094299iyx2d9ljh6i5rc6k
2016-04-23 05:50:24.461 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.course_material' doesn't exist
2016-04-23 05:50:24.481 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table course_material drop foreign key FK_e4tmf79knpcyxjfc41452wtlv
2016-04-23 05:50:24.481 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.course_material' doesn't exist
2016-04-23 05:50:24.501 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table forum drop foreign key FK_rynifmiry638ka6e08avmxl9x
2016-04-23 05:50:24.501 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.forum' doesn't exist
2016-04-23 05:50:24.533 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table mail_box drop foreign key FK_hodc1557iup5oc121suudg5hr
2016-04-23 05:50:24.533 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.mail_box' doesn't exist
2016-04-23 05:50:24.557 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table message drop foreign key FK_2kutjtgfjvk2m3i29668l0n3j
2016-04-23 05:50:24.557 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.message' doesn't exist
2016-04-23 05:50:24.577 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table message drop foreign key FK_lbhyy4gtgh0ojf80bc4aq6x45
2016-04-23 05:50:24.577 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.message' doesn't exist
2016-04-23 05:50:24.599 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table message_mailbox drop foreign key FK_eqau3hwhobsvhxr4b0m2xvuop
2016-04-23 05:50:24.599 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.message_mailbox' doesn't exist
2016-04-23 05:50:24.624 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table message_mailbox drop foreign key FK_d6vn0iflgf9k6jrbsqmwrdxjf
2016-04-23 05:50:24.624 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.message_mailbox' doesn't exist
2016-04-23 05:50:24.641 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table registered_user drop foreign key FK_jxpn3w33nyd74ygfsv0smd2i7
2016-04-23 05:50:24.641 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.registered_user' doesn't exist
2016-04-23 05:50:24.663 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table user_rating drop foreign key FK_3lpqe9rmerccjerpnxnhyiyhv
2016-04-23 05:50:24.663 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.user_rating' doesn't exist
2016-04-23 05:50:24.685 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table user_takes_course drop foreign key FK_7ra4qdylay0p2622re8tobacb
2016-04-23 05:50:24.685 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.user_takes_course' doesn't exist
2016-04-23 05:50:24.708 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table user_takes_course drop foreign key FK_md8p234kyrbc3unoaaqytxpre
2016-04-23 05:50:24.708 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.user_takes_course' doesn't exist
2016-04-23 05:50:26.899 INFO 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2016-04-23 05:50:26.952 INFO 11585 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5ffb21e1: startup date [Sat Apr 23 05:50:21 CEST 2016]; root of context hierarchy
2016-04-23 05:50:26.956 INFO 11585 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/home],methods=[GET]}" onto public org.springframework.web.servlet.ModelAndView com.mycompany.app.controllers.HomeController.home(org.springframework.ui.Model)
2016-04-23 05:50:26.956 INFO 11585 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/welcome]}" onto public com.mycompany.app.controllers.Welcome com.mycompany.app.controllers.WelcomeController.welcome(java.lang.String)
2016-04-23 05:50:26.957 INFO 11585 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-04-23 05:50:26.957 INFO 11585 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-04-23 05:50:26.962 INFO 11585 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-04-23 05:50:26.962 INFO 11585 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-04-23 05:50:26.968 INFO 11585 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-04-23 05:50:27.033 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
2016-04-23 05:50:27.033 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.033 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.033 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2016-04-23 05:50:27.034 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/env || /env.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.034 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2016-04-23 05:50:27.034 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.034 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.034 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/info || /info.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.034 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.034 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.034 INFO 11585 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2016-04-23 05:50:27.052 WARN 11585 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : Unable to start LiveReload server
2016-04-23 05:50:27.076 INFO 11585 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-04-23 05:50:27.078 INFO 11585 --- [ restartedMain] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2016-04-23 05:50:27.100 INFO 11585 --- [ restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-04-23 05:50:27.101 INFO 11585 --- [ restartedMain] com.mycompany.app.App : Storing a few customers...
2016-04-23 05:50:27.431 INFO 11585 --- [ restartedMain] com.mycompany.app.App : Started App in 5.693 seconds (JVM running for 773.917)
2016-04-23 05:50:34.376 INFO 11585 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-04-23 05:50:34.376 INFO 11585 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-04-23 05:50:34.398 INFO 11585 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 22 ms
我已经看到了另一个类似的问题,但无论如何我都不知道如何解决它。这很奇怪,因为在某些情况下,同样的错误似乎出现了两次,例如
2016-04-23 05:50:24.405 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table comment drop foreign key FK_i2t738wo4x3tdcmbhqgomubmg
2016-04-23 05:50:24.405 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.comment' doesn't exist
2016-04-23 05:50:24.423 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table comment drop foreign key FK_t0dkmpiim1vamsp4gk8prew3n
2016-04-23 05:50:24.423 ERROR 11585 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'Group2SEA2016.comment' doesn't exist
请注意,显然这不会影响对某个网址请求的响应......
修改
我忘了提。我拥有在此数据库中删除和创建表的所有权限。我使用Spring重新创建表,这是我的application.properties
文件:
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://path_to_server/Group2SEA2016
spring.datasource.username=my_user
spring.datasource.password=my_password
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create-drop
有了这个,我想在每次从@Entity
类重新创建它们之前删除表...
答案 0 :(得分:0)
错误出现两次并不奇怪。每次失败的操作都会出现一次错误。正在执行两个不同的ALTER TABLE语句。
: HHH000389: Unsuccessful: alter table comment drop foreign key FK_i2t738wo4x3tdcmbhqgomubmg
: Table 'Group2SEA2016.comment' doesn't exist
: HHH000389: Unsuccessful: alter table comment drop foreign key FK_t0dkmpiim1vamsp4gk8prew3n
: Table 'Group2SEA2016.comment' doesn't exist
错误的原因可能正是错误消息所说的。看起来它引用了comment
数据库中名为Group2SEA2016
的表。
表格可能不存在。或者,可能是表存在,但您要连接的用户没有表的权限。
在某些MySQL实例上,表名称区分大小写。可能有一个表名Comment
,但如果实例使用区分大小写的表名,则对表名comment
的引用不会匹配。
答案 1 :(得分:0)
我不确定这里,看到我的控制台在错误之前提供了更多信息(我猜你只复制了错误,而不是之前的信息行),但我的错误在哪里相同。 我的问题似乎是我尝试使用保留名称(如)创建列。当我改变那个列名时,hibernate不再给出任何错误,我的数据库也正确了。