关于如何将 spring mvc 重构为普通 servlet 或 jetty handler 的建议
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用标准注释
@Inject
进行依赖注入。 Spring 和 Guice 都支持它。You can use the standard annotation
@Inject
for dependency injection. Both Spring and Guice support it.