简体   繁体   中英

Spring Web Application without any XML

Spring JavaConfig makes possible to create spring applications without xml cotext configuration. And servlet 3.0 specification makes possible to create web applications without web.xml.

So, is it possible to create spring web application not using any xml configuration? Is there any already implemented solution?

PS At now I do not see in servlet 3.0 any simple method to use Spring's DispatcherServlet and listener.

Well, don't expect too much support of Spring from Java EE 6 (which is officially out since yesterday) as this won't happen soon in my opinion :) In other words, you'll need to wait for Spring to support Servlet 3.0 to benefit from all facilities. Quoting the Spring Framework 3.0 RC1 released blog post:

* Last but not least, early support for Java EE 6: Spring 3.0 already supports the use of JSF 2.0 and JPA 2.0 in a Spring environment, in addition to JSR-303 and JSR-330 support. Further Java EE 6 related specifications such as Servlet 3.0 will be fully supported as they become available in concrete products; this is scheduled for the Spring 3.1/3.2 timeframe.

So you'll still need XML for now and this should answer your question.

So, is it possible to create spring web application not using any xml configuration?

Look like so, yes, when leaving under each the context.xml and several appserver-specific xml files outside consideration.

Is there any already implemented solution?

Why are you asking this? Did you bother to download the necessary software and play with it yourself? What problems exactly did you have with it? Java EE 6 isn't officially out yet (still in beta), so I wouldn't expect any real world live implementations.

Edit : as per your edit:

PS At now I do not see in servlet 3.0 any simple method to use Spring's DispatcherServlet and listener.

Sun don't care about Spring. Spring isn't part of Sun Java EE, Spring is just built on top of that. Spring is responsible for their own products themselves. So all you can do is to wait for them to release an upgraded product targeted on Java EE 6.

您是否使用过Grails.Its一个支持约定优于配置的Web框架(类似于rails上的ruby,因此没有配置文件的问题),我认为在后端生成符合Spring框架的代码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM