关于如何将 spring mvc 重构为普通 servlet 或 jetty handler 的建议

发布于 2024-12-29 00:28:42 字数 515 浏览 1 评论 0原文

我有一个 spring mvc 应用程序,我想重构它,专门删除 spring 相关的代码和接线。

此时它是一个简单的 spring mvc,所以我必须做依赖注入的关键事情。

我的 application.xml 有我的 Dao 对象的连接,将数据源注入到我的 Dao 对象中。

我现在如何使用与 Spring 无关的 DI?我必须改变什么?除非你们另有推荐,否则我想使用 guice

application.xml:

<bean id="userDao" class="com.blah.dao.UserDaoImpl">
 <property name="dataSource" ref="dataSource" />
</bean>

您建议我现在使用什么来设置数据源和连接池?

实际的页面/url 映射特定于 if我选择 servlet 或码头处理程序。

I have a spring mvc app that I want to refactor out, speficially removing the spring related code and wiring.

It is a simple spring mvc at this point, so the key things I have to do our dependancy injection.

My application.xml has wirings for my Dao objects, injecting the datasource into my Dao objects.

How can I use a spring agnostic DI now? What do I have to change? I want to use guice unless you guys recommend otherwise

application.xml:

<bean id="userDao" class="com.blah.dao.UserDaoImpl">
 <property name="dataSource" ref="dataSource" />
</bean>

What do you suggest I use to setup my datasource and connection pooling now?

The actual page/url mapping is specific to if I choose servlets or a jetty handler.

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

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

发布评论

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

评论(1

踏雪无痕 2025-01-05 00:28:42

您可以使用标准注释@Inject进行依赖注入。 Spring 和 Guice 都支持它。

You can use the standard annotation @Inject for dependency injection. Both Spring and Guice support it.

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