Spring Boot Dev Tools要将其关闭以进行生产吗? [英] Spring Boot Dev Tools Turning them off for production?

查看:133
本文介绍了Spring Boot Dev Tools要将其关闭以进行生产吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了很多有关spring开发工具的文章,并且尝试过它们,它们看起来很酷.但是,我不了解如何启用/禁用它们.例如,仅添加依赖关系,一切都会神奇地起作用,但是如果我想将代码部署到生产中怎么办?开发工具是否仍在运行,我需要使用配置文件或其他工具将其禁用?

I was reading around a lot about spring dev tools and I have tried them on and they seem pretty cool. However, I don't understand how they get enabled / disabled. For instance just adding the dependency, everything magically works, but what if I wanted to deploy my code to production? Are the dev tools still running and I need to disable them with a profile or something?

推荐答案

否,它会自动关闭.

来自

在完全运行时会自动禁用开发人员工具 打包的应用程序.如果您的应用程序是使用java -jar启动的 或者,如果它开始使用特殊的类加载器,则将其视为 生产申请".将依赖项标记为可选是 防止devtools过渡应用的最佳实践 到使用您的项目的其他模块. Gradle不支持可选 开箱即用的依赖项,因此您可能需要看看 同时使用propdeps-plugin.

Developer tools are automatically disabled when running a fully packaged application. If your application is launched using java -jar or if it’s started using a special classloader, then it is considered a "production application". Flagging the dependency as optional is a best practice that prevents devtools from being transitively applied to other modules using your project. Gradle does not support optional dependencies out-of-the-box so you may want to have a look to the propdeps-plugin in the meantime.

如果您要确保devtools不包含在生产中 构建,您可以使用excludeDevtools构建属性来完全 删除JAR. Maven和Maven都支持该属性 Gradle插件.

If you want to ensure that devtools is never included in a production build, you can use the excludeDevtools build property to completely remove the JAR. The property is supported with both the Maven and Gradle plugins.

这篇关于Spring Boot Dev Tools要将其关闭以进行生产吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆