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.
Spring MVC web applications use the web. xml file as a deployment descriptor file. Also, it defines mappings between URL paths and the servlets in the web. xml file.
XML Still Needed Even, with all the features introduced in Servlet 3.0, there are some use cases where we'll still need a web. xml file, among them: We can't define the filter order with annotations – we still need the <filter-mapping> section if we have multiple filters that we need to be applied in a particular order.
XML is not required for Spring configuration. You can configure Spring with pure Java-based configuration (annotations). For example, instead of using the XML you posted in your question you can create a class with @Configuration and @ComponentScan annotations: @Configuration @ComponentScan(basePackages = {"com.
No, there will be no need of web. xml for servlet based application if you are using servlet version >3.0 and tomcat 7 as it will not run in the previous versions of tomcat. Annotation represents the metadata. If you use annotation, deployment descriptor (web.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With