Maven 配置文件或弹簧配置文件? [英] maven profiles or spring profiles?

查看:66
本文介绍了Maven 配置文件或弹簧配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多 java 应用程序都是用 maven 构建的.maven 有 Profiles 的概念,为不同的环境构建发布包真的很方便.例如dev/test/prod 使用不同的path/jndiname/security rule/properties files...我想我不必在这里列出代码来解释它.>

Spring 是一个非常好的和流行的 Java 开发框架,因为 spring3 它也支持配置文件概念.

现在问题来了,对于发布到不同的ENV目的,哪个更好?现在我更喜欢 Maven 配置文件.因为 spring 必须复制每个配置文件中的每个 bean 定义.并且它需要一个初始化程序/属性来让 spring 知道应该激活哪个配置文件.

但我觉得 spring 配置文件比 maven 配置文件更灵活.

你怎么看?请给一些建议.谢谢.

解决方案

Maven 配置文件将提供构建时解决方案,而 SpringFramework 配置文件将提供运行时替代方案.我想这是人们可能会问自己的第一个问题:他是否想要一个可以部署在不同环境中的单一包,或者他是否想要构建工具根据目标环境提供不同的包.

要记住的一件事是,如果您将不同的包部署到不同的服务器中,可能会出现许多问题.例如,在我的工作场所,如果我正在部署一个包来纠正以前在生产环境中出现的错误,公司政策会规定唯一可接受的情况是我在 QA 和生产服务器中拥有相同的解决方案包.

a lot java applications are build with maven. maven has Profiles concept, it is really handy to build release package for different environments. e.g. dev/test/prod using different path / jndiname / security rule / properties files... I think I don't have to list codes here to explain it.

Spring is a very nice and popular framework for java development, since spring3 it has supported profiles concept too.

Now question comes, for releasing to different ENVs purpose, which one is better? right now I prefer maven profile. since spring has to copy each bean definition in each profile. and it needs an initializer/property to let spring know which profile should be actived.

but I feel spring profile is more flexible than maven profile.

what do you think? please give some advices. thank you.

解决方案

Maven profiles would provide a build-time solution, while SpringFramework profiles would provide a runtime alternative. I think this is the first question one may ask himself: if he wants to have a single package that can be deployed in different environments, or if he wants the build tool to provide different packages according to the destination environment.

One thing to keep in mind is that many questions may arise if you have different packages deployed into different servers. In my workplace, for example, if I am deploying a package to correct a bug previously occurred in production environment, a company policy would state that the only acceptable scenario is that I have the same solution package in QA and in production servers.

这篇关于Maven 配置文件或弹簧配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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