gpt4 book ai didi

java - 在Gradle + Spring Boot中创建任务以设置默认配置文件?

转载 作者:行者123 更新时间:2023-12-03 05:46:38 26 4
gpt4 key购买 nike

我只想在运行gradleRun时设置默认配置文件,但是cannot find method run()失败

我首先想知道:

buildscript对我有什么作用,我如何成功使用spring-boot插件

Could not find method bootRun() for arguments [build_74d21ufxy8p9tyrqny7v4pkut$_run_closure1@389a9e15] on root project 'core' of type org.gradle.api.Project.


buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.1.RELEASE"
}
}

task local {
run { systemProperty "spring.profiles.active", "development" }
}

bootRun.mustRunAfter local

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'maven'
apply plugin: 'spring-boot'

group = 'com.remindful'
version = '1.0.0-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
mavenCentral()
}

最佳答案

去掉

task local {
run { systemProperty "spring.profiles.active", "development" }
}
bootRun.mustRunAfter local


bootRun {
systemProperty "spring.profiles.active", "development"
}

要回答有关构建脚本和spring-boot插件的问题,构建脚本包含使用gradle构建项目所需的任务,这是简单的描述,请检查 documentation。 Spring 启动插件

allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot-dependencies



您可以引用文档 here

关于java - 在Gradle + Spring Boot中创建任务以设置默认配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49889866/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com