Spring MVC(xml 配置噩梦?) vs spring roo?

发布于 2024-12-11 17:48:33 字数 263 浏览 0 评论 0原文

我正在深入研究 spring mvc (或 spring roo),从我读到的内容来看,spring mvc 的配置似乎是一场噩梦。我必须配置 XML 文件,这是 web.xml 文件吗???或者有什么不同?

它仍然是一场噩梦还是已经有所改善?

这些 XML 文件没有编辑器吗?我正在使用 eclipse IDE

Spring roo 显然没有 spring mvc 的 XML 配置担忧。

我希望有人能解释这些差异..

提前致谢

I am just delving into the spring mvc (or spring roo), from what i have read it appears that spring MVC can be a nightmare to configure. I have to configure XML files, is this the web.xml file??? Or something different?

Is it still a nightmare or has it been improved?

Is there no editor for these XML files? I am using eclipse IDE

Spring roo apparently does spring mvc without XML config worries.

I would love anyone to explain the differences..

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情释 2024-12-18 17:48:33

首先 Spring MVC 的配置并不是一场噩梦,你只需要知道你在做什么。

为此,我建议您下载 Spring IDE,它有很多 XML 编辑器,如果您没有使用 Spring XML 的经验,这些编辑器可以让您的生活更轻松。

基本上你必须配置两件事

  • Web.xml(这不是因为Spring它是Java EE,而是你
    需要在其中包含一些 spring MVC 配置)
  • applicationContext.xml(这是您定义 Spring 所需内容的位置)
  • servlet-context.xml(这也来自 spring MVC,并且有一些 servlet 定义以及一些路由定义)

一当你了解它们后,你会发现它很容易配置并且非常灵活。

需要注意的一件事是 Spring 和 Spring MVC 是不同的东西,我建议你学习它们。

Spring Roo 也是一个代码生成器,对于 Cruds、简单的事情和设置项目来说它很棒,但是如果您需要构建一个需要支持的合理的大型应用程序,那么您自己创建所有内容总是更容易,因为当您知道代码时更容易支持,所以请小心使用。

First Spring MVC is not a nightmare to configure, you just have to know what you are doing.

For that I would suggest you to download Spring IDE, which have a lot of XML editors that make you life easier if you are not experienced with Spring XMLs.

Basicly you have to configure 2 things

  • Web.xml ( this one is not because of spring it's Java EE, but you
    need to include some spring MVC configs in it )
  • applicationContext.xml( this is where you define what you want from Spring )
  • servlet-context.xml ( this is also from spring MVC and have some servlet definitions as well as some routing ones)

one you get to know them you will find it easy to configure and very flexible.

One thing to notice Spring and Spring MVC are different things, I advise you to learn both of them.

Also Spring Roo is a code generator, for Cruds, simple things and setup projects it's great but if you need to build a reasonable big app that will need support it's always easier to create everything youself because it's easier to support when you know the code, so use it with care.

少钕鈤記 2024-12-18 17:48:33

我想补充一点,Spring XML 配置可以简单到几行,大部分工作都是通过注释完成的。这样做可能并不总是更好,但这是一种选择。当有意义时,可以在机制之间划分配置。

您可能需要花一些时间阅读 Spring 文档,至少是有关您正在使用的组件的文档。如果您认为配置它是一场噩梦,那么等到您必须在不了解底层框架如何工作的情况下诊断基于约定的魔法带来的问题时。

I'd add that Spring XML configuration can be as simple as a few lines, with the bulk of work done via annotations. It may not always be preferable to do it that way, but it's an option. Configuration can be divided between mechanisms when it makes sense to do so.

You might want to spend some time with the Spring documentation, at least regarding the components you're using. If you think configuring it is a nightmare, wait until you have to diagnose a problem brought about by magic based on convention without understanding how the underlying framework(s) work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文