超爱学习网
gradle
一级目录
概念讲解
命令使用
面试题
二级目录
命令
gradle build
gradle clean
gradle compileJava
gradle test
gradle assemble
gradle check
gradle tasks
gradle dependencies
gradle help
gradle init
gradle wrapper
gradle publish
gradle eclipse
gradle idea
gradle bootRun

「 bootRun 」概念和作用

Gradle中的`bootRun`任务是Spring Boot插件提供的一个任务,用于启动Spring Boot应用程序。它会自动检测项目中的主类,并运行该主类,启动嵌入式的Tomcat服务器或其他Web容器,使您可以在开发期间快速启动和测试应用。

案例1. 使用默认配置启动Spring Boot应用

gradlew bootRun

案例2. 指定主类启动应用

gradlew bootRun --args='--main-class=com.example.MyApplication'

案例3. 指定自定义的HTTP端口

gradlew bootRun --args='--server.port=8081'

案例4. 使用自定义的配置文件

gradlew bootRun --args='--spring.config.name=myapp --spring.config.location=classpath:/custom-config.properties'

案例5. 启用远程调试

gradlew bootRun --debug-jvm

案例6. 指定启动参数

gradlew bootRun --args='--my-custom-arg=value'

案例7. 使用不同的环境配置

gradlew bootRun --args='--spring.profiles.active=dev'

案例8. 启用热部署

gradlew bootRun --args='--spring.devtools.restart.enabled=true'

案例9. 设置日志级别

gradlew bootRun --args='--logging.level.com.example=DEBUG'

案例10. 使用自定义的配置文件目录

gradlew bootRun --args='--spring.config.name=myapp --spring.config.additional-location=file:/path/to/custom-config.properties'