spring 启动ApplicationContext时出错,若要显示条件评估报告,请在启用“debug”的情况下重新运行应用程序,

t1qtbnec  于 2023-09-29  发布在  Spring
关注(0)|答案(1)|浏览(138)

我从《Spring在行动》这本书开始学习Spring。当我读到第3章时,我遇到了一个问题,这一章涉及关系数据库。当我似乎已经做了一切,错误出现在启动时,我不知道为什么

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  5. http://maven.apache.org/xsd/maven-4.0.0.xsd">
  6. <modelVersion>4.0.0</modelVersion>
  7. <groupId>sia</groupId>
  8. <artifactId>taco-cloud</artifactId>
  9. <version>0.0.3-SNAPSHOT</version>
  10. <packaging>jar</packaging>
  11. <name>taco-cloud</name>
  12. <description>Taco Cloud Example</description>
  13. <parent>
  14. <groupId>org.springframework.boot</groupId>
  15. <artifactId>spring-boot-starter-parent</artifactId>
  16. <version>3.1.2</version>
  17. <relativePath /> <!-- lookup parent from repository -->
  18. </parent>
  19. <properties>
  20. <project.build.sourceEncoding>
  21. UTF-8</project.build.sourceEncoding>
  22. <project.reporting.outputEncoding>
  23. UTF-8</project.reporting.outputEncoding>
  24. <java.version>19</java.version>
  25. </properties>
  26. <dependencies>
  27. <dependency>
  28. <groupId>org.springframework.boot</groupId>
  29. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  30. </dependency>
  31. <dependency>
  32. <groupId>org.springframework.boot</groupId>
  33. <artifactId>spring-boot-starter-web</artifactId>
  34. </dependency>
  35. <dependency>
  36. <groupId>org.springframework.boot</groupId>
  37. <artifactId>spring-boot-starter-test</artifactId>
  38. <scope>test</scope>
  39. </dependency>
  40. <dependency>
  41. <groupId>org.springframework.boot</groupId>
  42. <artifactId>spring-boot-devtools</artifactId>
  43. <scope>runtime</scope>
  44. </dependency>
  45. <dependency>
  46. <groupId>org.seleniumhq.selenium</groupId>
  47. <artifactId>selenium-java</artifactId>
  48. <scope>test</scope>
  49. </dependency>
  50. <dependency>
  51. <groupId>org.seleniumhq.selenium</groupId>
  52. <artifactId>htmlunit-driver</artifactId>
  53. <scope>test</scope>
  54. </dependency>
  55. <dependency>
  56. <groupId>org.springframework.boot</groupId>
  57. <artifactId>spring-boot-starter-actuator</artifactId>
  58. </dependency>
  59. <dependency>
  60. <groupId>org.projectlombok</groupId>
  61. <artifactId>lombok</artifactId>
  62. <scope>provided</scope>
  63. </dependency>
  64. <!-- tag::springDataJdbc[] -->
  65. <dependency>
  66. <groupId>org.springframework.boot</groupId>
  67. <artifactId>spring-boot-starter-data-jdbc</artifactId>
  68. </dependency>
  69. <!-- end::springDataJdbc[] -->
  70. <dependency>
  71. <groupId>com.h2database</groupId>
  72. <artifactId>h2</artifactId>
  73. <scope>runtime</scope>
  74. </dependency>
  75. <dependency>
  76. <groupId>org.springframework.boot</groupId>
  77. <artifactId>spring-boot-starter</artifactId>
  78. </dependency>
  79. <dependency>
  80. <groupId>org.springframework.boot</groupId>
  81. <artifactId>spring-boot-starter-validation</artifactId>
  82. </dependency>
  83. <dependency>
  84. <groupId>javax.validation</groupId>
  85. <artifactId>validation-api</artifactId>
  86. <version>2.0.1.Final</version>
  87. </dependency>
  88. </dependencies>
  89. <build>
  90. <plugins>
  91. <plugin>
  92. <groupId>org.springframework.boot</groupId>
  93. <artifactId>spring-boot-maven-plugin</artifactId>
  94. </plugin>
  95. </plugins>
  96. </build>
  97. <repositories>
  98. <repository>
  99. <id>spring-milestones</id>
  100. <name>Spring Milestones</name>
  101. <url>https://repo.spring.io/milestone</url>
  102. </repository>
  103. </repositories>
  104. <pluginRepositories>
  105. <pluginRepository>
  106. <id>spring-milestones</id>
  107. <name>Spring Milestones</name>
  108. <url>https://repo.spring.io/milestone</url>
  109. </pluginRepository>
  110. </pluginRepositories>
  111. </project

我不严格判断,我还是新的Spring,这些都是我的错误

  1. > these are errors
  2. > Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
  3. 2023-09-06T15:27:34.553+03:00 ERROR 7068 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
  4. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'designTacoController' defined in file [C:\Users\Artem\IdeaProjects\taco-cloud\taco-cloud\target\classes\tacos\web\DesignTacoController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'ingredientRepository': Unsatisfied dependency expressed through method 'setDialect' parameter 0: Error creating bean with name 'jdbcDialect' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Unsatisfied dependency expressed through method 'jdbcDialect' parameter 0: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Failed to execute SQL script statement #6 of file [C:\Users\Artem\IdeaProjects\taco-cloud\taco-cloud\target\classes\schema.sql]: alter table Ingredient_Ref add foreign key (ingredient) references Ingredient(id)
  5. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-6.0.11.jar:6.0.11]
  6. at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245) ~[spring-beans-6.0.11.jar:6.0.11]
  7. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-6.0.11.jar:6.0.11]
  8. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1189) ~[spring-beans-6.0.11.jar:6.0.11]
  9. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) ~[spring-beans-6.0.11.jar:6.0.11]
  10. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.11.jar:6.0.11]
  11. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.11.jar:6.0.11]
  12. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.11.jar:6.0.11]
  13. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.11.jar:6.0.11]
  14. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
  15. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) ~[spring-beans-6.0.11.jar:6.0.11]
  16. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:942) ~[spring-context-6.0.11.jar:6.0.11]
  17. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.11.jar:6.0.11]
  18. at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.2.jar:3.1.2]
  19. at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-3.1.2.jar:3.1.2]
  20. at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[spring-boot-3.1.2.jar:3.1.2]
  21. at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-3.1.2.jar:3.1.2]
  22. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-3.1.2.jar:3.1.2]
  23. at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-3.1.2.jar:3.1.2]
  24. at tacos.TacoCloudApplication.main(TacoCloudApplication.java:14) ~[classes/:na]
  25. at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[na:na]
  26. at java.base/java.lang.reflect.Method.invoke(Method.java:578) ~[na:na]
  27. at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:50) ~[spring-boot-devtools-3.1.2.jar:3.1.2]
  28. Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ingredientRepository': Unsatisfied dependency expressed through method 'setDialect' parameter 0: Error creating bean with name 'jdbcDialect' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Unsatisfied dependency expressed through method 'jdbcDialect' parameter 0: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Failed to execute SQL script statement #6 of file [C:\Users\Artem\IdeaProjects\taco-cloud\taco-cloud\target\classes\schema.sql]: alter table Ingredient_Ref add foreign key (ingredient) references Ingredient(id)
  29. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:825) ~[spring-beans-6.0.11.jar:6.0.11]
  30. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:778) ~[spring-beans-6.0.11.jar:6.0.11]
  31. at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:145) ~[spring-beans-6.0.11.jar:6.0.11]
  32. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:483) ~[spring-beans-6.0.11.jar:6.0.11]
  33. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1416) ~[spring-beans-6.0.11.jar:6.0.11]
  34. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:597) ~[spring-beans-6.0.11.jar:6.0.11]
  35. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.11.jar:6.0.11]
  36. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.11.jar:6.0.11]
  37. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.11.jar:6.0.11]
  38. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.11.jar:6.0.11]
  39. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
  40. at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.11.jar:6.0.11]
  41. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417) ~[spring-beans-6.0.11.jar:6.0.11]
  42. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) ~[spring-beans-6.0.11.jar:6.0.11]
  43. at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888) ~[spring-beans-6.0.11.jar:6.0.11]
  44. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-6.0.11.jar:6.0.11]
  45. ... 22 common frames omitted
  46. Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jdbcDialect' defined in class path resource [org/springframework/boot/autoconfigure/data/jdbc/JdbcRepositoriesAutoConfiguration$SpringBootJdbcConfiguration.class]: Unsatisfied dependency expressed through method 'jdbcDialect' parameter 0: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Failed to execute SQL script statement #6 of file [C:\Users\Artem\IdeaProjects\taco-cloud\taco-cloud\target\classes\schema.sql]: alter table Ingredient_Ref add foreign key (ingredient) references Ingredient(id)
  47. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-6.0.11.jar:6.0.11]
  48. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:550) ~[spring-beans-6.0.11.jar:6.0.11]
  49. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1332) ~[spring-beans-6.0.11.jar:6.0.11]
  50. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1162) ~[spring-beans-6.0.11.jar:6.0.11]
  51. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) ~[spring-beans-6.0.11.jar:6.0.11]
  52. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.11.jar:6.0.11]
  53. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.11.jar:6.0.11]
  54. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.11.jar:6.0.11]
  55. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.11.jar:6.0.11]
  56. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
  57. at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.11.jar:6.0.11]
  58. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417) ~[spring-beans-6.0.11.jar:6.0.11]
  59. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) ~[spring-beans-6.0.11.jar:6.0.11]
  60. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:817) ~[spring-beans-6.0.11.jar:6.0.11]
  61. ... 37 common frames omitted
  62. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Failed to execute SQL script statement #6 of file [C:\Users\Artem\IdeaProjects\taco-cloud\taco-cloud\target\classes\schema.sql]: alter table Ingredient_Ref add foreign key (ingredient) references Ingredient(id)
  63. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-6.0.11.jar:6.0.11]
  64. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.11.jar:6.0.11]
  65. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.11.jar:6.0.11]
  66. at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.11.jar:6.0.11]
  67. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.11.jar:6.0.11]
  68. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.11.jar:6.0.11]
  69. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
  70. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:313) ~[spring-beans-6.0.11.jar:6.0.11]
  71. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.11.jar:6.0.11]
  72. at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.11.jar:6.0.11]
  73. at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417) ~[spring-beans-6.0.11.jar:6.0.11]
  74. at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) ~[spring-beans-6.0.11.jar:6.0.11]
  75. at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888) ~[spring-beans-6.0.11.jar:6.0.11]
  76. at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-6.0.11.jar:6.0.11]
  77. ... 50 common frames omitted
  78. Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #6 of file [C:\Users\Artem\IdeaProjects\taco-cloud\taco-cloud\target\classes\schema.sql]: alter table Ingredient_Ref add foreign key (ingredient) references Ingredient(id)
  79. at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:282) ~[spring-jdbc-6.0.11.jar:6.0.11]
  80. at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254) ~[spring-jdbc-6.0.11.jar:6.0.11]
  81. at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:54) ~[spring-jdbc-6.0.11.jar:6.0.11]
  82. at org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer.runScripts(DataSourceScriptDatabaseInitializer.java:87) ~[spring-boot-3.1.2.jar:3.1.2]
  83. at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.runScripts(AbstractScriptDatabaseInitializer.java:146) ~[spring-boot-3.1.2.jar:3.1.2]
  84. at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.applyScripts(AbstractScriptDatabaseInitializer.java:108) ~[spring-boot-3.1.2.jar:3.1.2]
  85. at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.applySchemaScripts(AbstractScriptDatabaseInitializer.java:98) ~[spring-boot-3.1.2.jar:3.1.2]
  86. at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.initializeDatabase(AbstractScriptDatabaseInitializer.java:76) ~[spring-boot-3.1.2.jar:3.1.2]
  87. at org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer.afterPropertiesSet(AbstractScriptDatabaseInitializer.java:66) ~[spring-boot-3.1.2.jar:3.1.2]
  88. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-6.0.11.jar:6.0.11]
  89. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.11.jar:6.0.11]
  90. ... 63 common frames omitted
  91. Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Ограничение "PRIMARY KEY | UNIQUE (ID)" не найдено
  92. Constraint "PRIMARY KEY | UNIQUE (ID)" not found; SQL statement:
  93. alter table Ingredient_Ref add foreign key (ingredient) references Ingredient(id) [90057-214]
  94. at org.h2.message.DbException.getJdbcSQLException(DbException.java:632) ~[h2-2.1.214.jar:2.1.214]
  95. at org.h2.message.DbException.getJdbcSQLException(DbException.java:477) ~[h2-2.1.214.jar:2.1.214]
  96. at org.h2.message.DbException.get(DbException.java:223) ~[h2-2.1.214.jar:2.1.214]
  97. at org.h2.message.DbException.get(DbException.java:199) ~[h2-2.1.214.jar:2.1.214]
  98. at org.h2.command.ddl.AlterTableAddConstraint.tryUpdate(AlterTableAddConstraint.java:258) ~[h2-2.1.214.jar:2.1.214]
  99. at org.h2.command.ddl.AlterTableAddConstraint.update(AlterTableAddConstraint.java:72) ~[h2-2.1.214.jar:2.1.214]
  100. at org.h2.command.ddl.AlterTable.update(AlterTable.java:46) ~[h2-2.1.214.jar:2.1.214]
  101. at org.h2.command.CommandContainer.update(CommandContainer.java:169) ~[h2-2.1.214.jar:2.1.214]
  102. at org.h2.command.Command.executeUpdate(Command.java:252) ~[h2-2.1.214.jar:2.1.214]
  103. at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:252) ~[h2-2.1.214.jar:2.1.214]
  104. at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223) ~[h2-2.1.214.jar:2.1.214]
  105. at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) ~[HikariCP-5.0.1.jar:na]
  106. at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-5.0.1.jar:na]
  107. at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:261) ~[spring-jdbc-6.0.11.jar:6.0.11]
  108. ... 73 common frames omitted
  109. Process finished with exit code 0
  110. >
czq61nw1

czq61nw11#

真正的问题是:
引起:org.h2.jdbc.JdbcSQLSyntaxErrorException:主密钥|UNIQUE(ID)"н е н а й д е н о Constraint" PRIMARY KEY|未找到UNIQUE(ID)"; SQL语句:[90057 - 214]找不到该页时出现异常[90057 - 214] at org.h2.message.DbException.getJdbcSQLExException(DbException.java:632)~[h2 - 2.1.214.jar:Exception.java:400.cn~[h2 - 2.1.214.jar:]找不到网络异常。2.1.214] at org.h2.message.DbException.get(DbException.java:223)~[h2 - 2.1.214.jar:2.1.214] at org.h2.message.DbException.get(DbException.java:199)~[h2 - 2.1.214.jar:2.1.214] at org.h2.command.ddl.AlterTableAddConstraint.tryUpdate(AlterTableAddConstraint.java:258)~[h2 - 2.1.214.jar:2.1.214] at org.h2.command.ddl.AlterTableAddConstraint.update(AlterTableAddConstraint.java:72)~[h2 - 2.1.214.jar:2.1.214] at org.h2.command.ddl.AlterTable.update(AlterTable.java:46)~[h2 - 2.1.214.jar:2.1.214] at org.h2.command.CommandContainer.update(CommandContainer.java:169)~[h2 - 2.1.214.jar:2.1.214] at org.h2.command.Command.executeUpdate(Command.java:252)~[h2 - 2.1.214.jar:2.1.214] at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:252)~[h2 - 2.1.214.jar:2.1.214] at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223)~[h2 - 2.1.214.jar:2.1.214]在com. zaxxer。光。游泳池ProxyStatement. execute(ProxyStatement.java:94)~[HikariCP-5.0.1.jar:[a] at com. zaxxer。光。游泳池HikariProxyStatement. execute( www.example.com
H2文档说:
引用约束要求对被引用列有现有的唯一或主键约束
Ingredient中的id字段不是主键或没有唯一约束。

相关问题