
前提・実現したいこと
SpringBootを使ってWebアプリケーションを作っています。
DBFluteを使ってデータアクセスしようと思っています。
DBFluteのセットアップ後にBhvクラスをオートワイヤーし、
アプリケーションを立ち上げてみたのですが以下のエラーメッセージが発生しました。
解決方法わかる方がいらっしゃりましたらご教示お願いします。
発生している問題・エラーメッセージ
. ____ _ __ _ _ /\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ / _` | \ \ \ \ \/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.1.RELEASE) 2019-01-20 21:39:26.290 INFO 24160 --- [ restartedMain] com.oyu.sent.SentoApplication : Starting SentoApplication on MyComputer with PID 24160 (C:\pleiades\workspace\sento\target\classes started by mmasa in C:\pleiades\workspace\sento) 2019-01-20 21:39:26.293 INFO 24160 --- [ restartedMain] com.oyu.sent.SentoApplication : No active profile set, falling back to default profiles: default 2019-01-20 21:39:26.551 INFO 24160 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2019-01-20 21:39:26.552 INFO 24160 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 2019-01-20 21:39:28.792 INFO 24160 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2019-01-20 21:39:28.831 INFO 24160 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-01-20 21:39:28.831 INFO 24160 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13 2019-01-20 21:39:28.848 INFO 24160 --- [ restartedMain] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\pleiades\java\8\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/pleiades/eclipse/jre/bin/../jre/bin/server;C:/pleiades/eclipse/jre/bin/../jre/bin;C:/pleiades/eclipse/jre/bin/../jre/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Java\jdk1.8.0_161\bin;C:\apache-maven-3.5.3\bin;C:\Program Files\PuTTY\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\PostgreSQL\10\bin;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Users\mmasa\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\mmasa\AppData\Local\Programs\Python\Python36-32\;C:\Users\mmasa\AppData\Local\Microsoft\WindowsApps;;C:\pleiades\eclipse;;.] 2019-01-20 21:39:29.069 INFO 24160 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-01-20 21:39:29.069 INFO 24160 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2517 ms 2019-01-20 21:39:29.169 WARN 24160 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sentoService': Unsatisfied dependency expressed through field 'personalBhv'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personalBhv': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'DBFluteBeansJavaConfig': Unsatisfied dependency expressed through field '_dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=dataSource)} 2019-01-20 21:39:29.172 INFO 24160 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2019-01-20 21:39:29.200 INFO 24160 --- [ restartedMain] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-01-20 21:39:29.410 ERROR 24160 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Field _dataSource in com.sento.dbflute.allcommon.DBFluteBeansJavaConfig required a bean of type 'javax.sql.DataSource' that could not be found. The injection point has the following annotations: - @org.springframework.beans.factory.annotation.Autowired(required=true) The following candidates were found but could not be injected: - Bean method 'dataSource' in 'JndiDataSourceAutoConfiguration' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name' - Bean method 'dataSource' in 'XADataSourceAutoConfiguration' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager' Action: Consider revisiting the entries above or defining a bean of type 'javax.sql.DataSource' in your configuration.
該当のソースコード
package com.oyu.sent; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication(scanBasePackages={"com.oyu.sent", "com.sento.dbflute"}) public class SentoApplication { public static void main(String[] args) { SpringApplication.run(SentoApplication.class, args); } }
package com.sento.dbflute.allcommon; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Lazy; import org.dbflute.bhv.core.BehaviorCommandInvoker; import org.dbflute.bhv.core.InvokerAssistant; /** * The Java configuration of DBFlute beans for Spring Framework. <br> * You can inject them by importing this class in your auto configuration class. * @author DBFlute(AutoGenerator) */ @Configuration @ComponentScan(value="com.sento.dbflute.exbhv", lazyInit=true) public class DBFluteBeansJavaConfig { // =================================================================================== // Attribute // ========= @Autowired protected ApplicationContext _container; @Autowired @Qualifier("dataSource") protected DataSource _dataSource; // name basis here for multiple DB // =================================================================================== // Runtime Component // ================= @Bean(name="introduction") public DBFluteInitializer createDBFluteInitializer() { // no lazy for initialize-only component return new com.sento.dbflute.allcommon.DBFluteInitializer(_dataSource); } @Bean(name="invokerAssistant") @Lazy public InvokerAssistant createImplementedInvokerAssistant() { ImplementedInvokerAssistant assistant = newImplementedInvokerAssistant(); assistant.setDataSource(_dataSource); return assistant; } protected ImplementedInvokerAssistant newImplementedInvokerAssistant() { return new com.sento.dbflute.allcommon.ImplementedInvokerAssistant(); } @Bean(name="behaviorCommandInvoker") @Lazy public BehaviorCommandInvoker createBehaviorCommandInvoker() { BehaviorCommandInvoker invoker = newBehaviorCommandInvoker(); invoker.setInvokerAssistant(createImplementedInvokerAssistant()); return invoker; } protected BehaviorCommandInvoker newBehaviorCommandInvoker() { return new BehaviorCommandInvoker(); } @Bean(name="behaviorSelector") @Lazy public ImplementedBehaviorSelector createImplementedBehaviorSelector() { ImplementedBehaviorSelector selector = newImplementedBehaviorSelector(); selector.setContainer(_container); return selector; } protected ImplementedBehaviorSelector newImplementedBehaviorSelector() { return new ImplementedBehaviorSelector(); } @Bean(name="commonColumnAutoSetupper") @Lazy public ImplementedCommonColumnAutoSetupper createImplementedCommonColumnAutoSetupper() { return newImplementedCommonColumnAutoSetupper(); } protected ImplementedCommonColumnAutoSetupper newImplementedCommonColumnAutoSetupper() { return new ImplementedCommonColumnAutoSetupper(); } }
試したこと
補足情報(FW/ツールのバージョンなど)
Java8
MySQL8
DBFlute1.1.9
を使っています
回答2件
あなたの回答
tips
プレビュー