現在、下記のサイトを参考にしてSTSを使いSpringBootでWEBアプリ作成をしています。
リンク内容
手順通りに作成して実行したのですが下記のエラーが出てしまいました。
このorg.springframework.beans.factory.UnsatisfiedDependencyException:
はどういった意味でしょうか?
また、何が原因でエラーで起こるのでしょうか?
SQLにもスペルが正しくないとエラーが出ていますが確認したところ、文法は間違っていないと思います。
解決するため原因になりそうなjarファイルを削除してMAVENで更新し直したりしましたが解決できませんでした。
教えていただけると嬉しいです。
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-04-16 15:03:05.932 ERROR 16144 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'itemController': Unsatisfied dependency expressed through field 'itemService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'itemService': Unsatisfied dependency expressed through field 'itemMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'itemMapper' defined in file [C:\Users\kumai\OneDrive\仕事\個人\JAVA\WorkspaceJAVA\demo\target\classes\com\example\demo\mapper\ItemMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #1 of URL [file:/C:/Users/kumai/OneDrive/%e4%bb%95%e4%ba%8b/%e5%80%8b%e4%ba%ba/JAVA/WorkspaceJAVA/demo/target/classes/schema.sql]: CREATE TABLE IF NOT EXISTS item ( id bigint(20) NOT NULL AUTO_INCREMENT, name varchar(255), price real, vendor varchar(255), PRIMARY KEY (id), ) ENGINE=InnoDB DEFAULT CHARSET=utf8; nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: SQLステートメントに文法エラーがあります "CREATE TABLE IF NOT EXISTS ITEM ( ID BIGINT(20) NOT NULL AUTO_INCREMENT, NAME VARCHAR(255), PRICE REAL, VENDOR VARCHAR(255), PRIMARY KEY (ID), )[*] ENGINE=INNODB DEFAULT CHARSET=UTF8"; 期待されるステートメント "identifier" Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS ITEM ( ID BIGINT(20) NOT NULL AUTO_INCREMENT, NAME VARCHAR(255), PRICE REAL, VENDOR VARCHAR(255), PRIMARY KEY (ID), )[*] ENGINE=INNODB DEFAULT CHARSET=UTF8"; expected "identifier"; SQL statement: CREATE TABLE IF NOT EXISTS item ( id bigint(20) NOT NULL AUTO_INCREMENT, name varchar(255), price real, vendor varchar(255), PRIMARY KEY (id), ) ENGINE=InnoDB DEFAULT CHARSET=utf8 [42001-200] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:598) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:376) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1404) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$108/1776081523.getObject(Unknown Source) ~[na:na] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:847) ~[spring-beans-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.15.BUILD-SNAPSHOT.jar:5.1.15.BUILD-SNAPSHOT] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.14.BUILD-SNAPSHOT.jar:2.1.14.BUILD-SNAPSHOT] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.14.BUILD-SNAPSHOT.jar:2.1.14.BUILD-SNAPSHOT] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.14.BUILD-SNAPSHOT.jar:2.1.14.BUILD-SNAPSHOT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.14.BUILD-SNAPSHOT.jar:2.1.14.BUILD-SNAPSHOT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.14.BUILD-SNAPSHOT.jar:2.1.14.BUILD-SNAPSHOT] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.14.BUILD-SNAPSHOT.jar:2.1.14.BUILD-SNAPSHOT] at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_40] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_40] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_40] at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_40] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.14.BUILD-SNAPSHOT.jar:2.1.14.BUILD-SNAPSHOT]
SQL
1CREATE TABLE IF NOT EXISTS item ( 2 id bigint(20) NOT NULL AUTO_INCREMENT, 3 name varchar(255), 4 price real, 5 vendor varchar(255), 6 PRIMARY KEY (id), 7) ENGINE=InnoDB DEFAULT CHARSET=utf8;
回答2件
あなたの回答
tips
プレビュー