spring boot domaでファイル自動生成
解決済
回答 1
投稿
- 評価
- クリップ 0
- VIEW 1,404
前回の質問の派生です。
回答者様の答えを参考に
DBとの接続設定とビルド実行ができました。
ので次はdomaの機能を使い
entityやdaoを自動生成しようと思います。
build.gradleに以下を記述しましたが
エラーがでてビルドできておりません。
原因がわかる方、よろしくお願いします
}
build.gradle
buildscript {
ext {
springBootVersion = '2.1.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
group = 'sample'
version = 'sample'
sourceCompatibility = 8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-thymeleaf')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation( 'org.springframework.boot:spring-boot-starter-data-jpa')
runtimeOnly('org.postgresql:postgresql')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('org.springframework.security:spring-security-test')
annotationProcessor "org.seasar.doma.boot:doma-spring-boot-starter:1.1.1"
compile("org.seasar.doma.boot:doma-spring-boot-starter:1.1.1"){
exclude group: "org.springframework.boot"
}
}
configurations {
domaGenRuntime
}
repositories {
mavenCentral()
maven {url 'https://oss.sonatype.org/content/repositories/snapshots/'}
}
//新しく追加した箇所
dependencies {
domaGenRuntime 'org.seasar.doma:doma-gen:2.21.0'
domaGenRuntime 'org.postgresql:org.postgresql.Driver'
}
//新しく追加した箇所
task gen << {
ant.taskdef(resource: 'domagentask.properties',
classpath: configurations.domaGenRuntime.asPath)
ant.gen(url: 'jdbc:postgresql://postgres.aws.com:5432/sample', user:postgres '', password:postgres '') {
entityConfig()
daoConfig()
sqlConfig()
}
}
}
コンソール
* What went wrong:
Could not compile build file 'C:\pleiades\workspace\sample\build.gradle'.
> startup failed:
build file 'C:\pleiades\workspace\sample\build.gradle': 61: expecting EOF, found 'gen' @ line 61, column 6.
task gen << {
^
1 error
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 0s
-
気になる質問をクリップする
クリップした質問は、後からいつでもマイページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
クリップを取り消します
-
良い質問の評価を上げる
以下のような質問は評価を上げましょう
- 質問内容が明確
- 自分も答えを知りたい
- 質問者以外のユーザにも役立つ
評価が高い質問は、TOPページの「注目」タブのフィードに表示されやすくなります。
質問の評価を上げたことを取り消します
-
評価を下げられる数の上限に達しました
評価を下げることができません
- 1日5回まで評価を下げられます
- 1日に1ユーザに対して2回まで評価を下げられます
質問の評価を下げる
teratailでは下記のような質問を「具体的に困っていることがない質問」、「サイトポリシーに違反する質問」と定義し、推奨していません。
- プログラミングに関係のない質問
- やってほしいことだけを記載した丸投げの質問
- 問題・課題が含まれていない質問
- 意図的に内容が抹消された質問
- 過去に投稿した質問と同じ内容の質問
- 広告と受け取られるような投稿
評価が下がると、TOPページの「アクティブ」「注目」タブのフィードに表示されにくくなります。
質問の評価を下げたことを取り消します
この機能は開放されていません
評価を下げる条件を満たしてません
質問の評価を下げる機能の利用条件
この機能を利用するためには、以下の事項を行う必要があります。
- 質問回答など一定の行動
-
メールアドレスの認証
メールアドレスの認証
-
質問評価に関するヘルプページの閲覧
質問評価に関するヘルプページの閲覧
checkベストアンサー
+1
最後の } が余分なのと, ant.genの引数が誤っていますね。
task gen << {
ant.taskdef(resource: 'domagentask.properties', classpath: configurations.domaGenRuntime.asPath)
ant.gen(url: 'jdbc:postgresql://postgres.aws.com:5432/sample',
// Bad!! user:postgres '', password:postgres ''
user: 'postgres', password: 'postgres') {
entityConfig()
daoConfig()
sqlConfig()
}
}
投稿
-
回答の評価を上げる
以下のような回答は評価を上げましょう
- 正しい回答
- わかりやすい回答
- ためになる回答
評価が高い回答ほどページの上位に表示されます。
-
回答の評価を下げる
下記のような回答は推奨されていません。
- 間違っている回答
- 質問の回答になっていない投稿
- スパムや攻撃的な表現を用いた投稿
評価を下げる際はその理由を明確に伝え、適切な回答に修正してもらいましょう。
15分調べてもわからないことは、teratailで質問しよう!
- ただいまの回答率 88.34%
- 質問をまとめることで、思考を整理して素早く解決
- テンプレート機能で、簡単に質問をまとめられる
2019/01/25 22:39
(けどファイル作成されてなかった←)