質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

ORM

ORM(オブジェクト関係マッピング)はオブジェクト指向のシステムとリレーショナルデータベースの間でマッピングを行う技術です。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

Q&A

解決済

2回答

2323閲覧

DBFluteをつかってDBアクセスするSpringBootのWebアプリケーションが立ち上がらない

ifmmatsumoto

総合スコア10

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

ORM

ORM(オブジェクト関係マッピング)はオブジェクト指向のシステムとリレーショナルデータベースの間でマッピングを行う技術です。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

0グッド

0クリップ

投稿2019/01/20 13:11

前提・実現したいこと

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
を使っています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2019/01/20 13:44

https://teratail.com/users/jflute あたりに聞いたほうが早いきがするが サポートバージョンの書き方をみると Spring boot 2.x / Spring 5.x をサポートしてないようにみえるけどそこら編は確認してるの?
ifmmatsumoto

2019/01/20 14:03

Spring boot 2.xのバージョンでやっていました バージョン下げて確認してみます! アドバイスありがとうございます!
guest

回答2

0

自己解決

依存関係が足りていなかったようです
pomに以下の二つを追加したら解決しました

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> <version>2.1.2.RELEASE</version> </dependency> <dependency> <groupId>javax.transaction</groupId> <artifactId>javax.transaction-api</artifactId> <version>1.2</version> <scope>provided</scope> </dependency>

asahina1979さん、cutedogさん

情報ありがとうございました!
また何かあればよろしくお願いします!

投稿2019/01/27 13:06

ifmmatsumoto

総合スコア10

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

こんにちは。

私はDBFlute.NET版を使っていますが
わからないことは「DBFLuteの集い」っていうところで質問しています。
こちらはコミッターさんがいるので色々と教えてくれるかと思いますよ。
https://groups.google.com/forum/#!forum/dbflute

投稿2019/01/21 01:44

cutedog

総合スコア177

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

ifmmatsumoto

2019/01/21 04:57

こんなグループがあるんですね、ありがとうございます! こちらの方でも質問してみます
cutedog

2019/01/21 05:47

知っているかもですが、teratailの利用規約では 以下のようになっているので注意してくださいね。 他のサービスにも質問投稿をしたい(してしまった) teratailでは、マルチポスト*の推奨はしていません。 やむを得ず複数のサイトに質問を投稿された場合は、質問内容にマルチポストをする理由を書き、他のサイトの投稿へのリンクを貼ってください。また、解決した際には必ずteratail及びすべての投稿に解決した旨と、どのように解決したかを記載してください。 また、teratail上で誤って同じ質問を複数投稿してしまった場合は、質問の削除リクエストを送ってください。 ※「マルチポスト」とは、同じ内容の文章を複数のQ&Aサイトや掲示板などへ投稿することです。
ifmmatsumoto

2019/01/21 13:41

利用規約知らなかったです 危うく無断でマルチポストするとこでした~ ありがとうございます!
退会済みユーザー

退会済みユーザー

2019/01/21 14:27

こんなグループあるのかって DBFlute 公式サイトにDBFlute はここで質問してねって書いてあるんですが・・・・
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問