Maven dependency for whole org.springframework - spring

How to set Maven dependency for all org.springframework ?
I mean, how to do it in couple lines,instead of providing dependency for every module,e.g.:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
etc..
thank you for help

This answer is aimed to newer version 4.X.X
If you want to handle versions of dependencies more efficiently use this code before your <dependencies></dependencies> tags.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Benefit of using the BOM is that you no longer need to specify the version of dependency. So your dependencies should looks like:
<dependencies>
<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
</dependencies>

You can do it like
<properties>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>
<dependencies>
<!-- Core utilities used by other modules. Define this if you use Spring
Utility APIs (org.springframework.core.*/org.springframework.util.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Expression Language (depends on spring-core) Define this if you use
Spring Expression APIs (org.springframework.expression.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Bean Factory and JavaBeans utilities (depends on spring-core) Define
this if you use Spring Bean APIs (org.springframework.beans.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Aspect Oriented Programming (AOP) Framework (depends on spring-core,
spring-beans) Define this if you use Spring AOP APIs (org.springframework.aop.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Application Context (depends on spring-core, spring-expression, spring-aop,
spring-beans) This is the central artifact for Spring's Dependency Injection
Container and is generally always defined -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Various Application Context utilities, including EhCache, JavaMail,
Quartz, and Freemarker integration Define this if you need any of these integrations -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Transaction Management Abstraction (depends on spring-core, spring-beans,
spring-aop, spring-context) Define this if you use Spring Transactions or
DAO Exception Hierarchy (org.springframework.transaction.*/org.springframework.dao.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context,
spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA,
and iBatis. (depends on spring-core, spring-beans, spring-context, spring-tx)
Define this if you need ORM (org.springframework.orm.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB,
JiBX, Castor, XStream, and XML Beans. (depends on spring-core, spring-beans,
spring-context) Define this if you need OXM (org.springframework.oxm.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Web application development utilities applicable to both Servlet and
Portlet Environments (depends on spring-core, spring-beans, spring-context)
Define this if you use Spring MVC, or wish to use Struts, JSF, or another
web framework with Spring (org.springframework.web.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Spring MVC for Servlet Environments (depends on spring-core, spring-beans,
spring-context, spring-web) Define this if you use Spring MVC with a Servlet
Container such as Apache Tomcat (org.springframework.web.servlet.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Spring MVC for Portlet Environments (depends on spring-core, spring-beans,
spring-context, spring-web) Define this if you use Spring MVC with a Portlet
Container (org.springframework.web.portlet.*) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Support for testing Spring applications with tools such as JUnit and
TestNG This artifact is generally always defined with a 'test' scope for
the integration testing framework and unit testing stubs -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>

As noted in other answers, you only want to use what you actually need, e.g. if you need the Spring Web framework, then get that. However, you can greatly simplify and reduce the set of dependencies listed in your pom.xml by doing a bit of dependency analysis and only specifying the highest level of required dependency.
So for example, suppose you have the following dependencies (note that I'm using the artifact IDs for the Spring EBR repository instead of Maven Central; see this article for more info on the difference):
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.context</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web.servlet</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.transaction</artifactId>
<version>${org.springframework-version}</version>
</dependency>
As it happens, though, the Spring Web stuff actually already has a dependency on the context library, so you can just remove the context reference:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web.servlet</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.transaction</artifactId>
<version>${org.springframework-version}</version>
</dependency>
This will get you the context library without specifically referencing it, since it's brought in implicitly by the dependency in the Web library.
If you have IntelliJ or m2eclipse or something like that in your IDE, you can get these dependencies displayed right in the IDE, either through a dependency hierarchy display or even in a dependency graph, which is basically a UML chart.
For stand-alone Maven, I think you just do:
mvn dependencies:list
More on the dependencies plugin is on the plugin site.
This approach keeps your dependencies very explicit and your application footprint much smaller, which is basically what everyone else is warning about, but can reduce the number of dependencies you have to list in your pom.xml, which is what I think you're trying to solve.

Create module with packaging pom and list all Spring dependencies there. Call it something like SpringDependencies.
Then in each of your modules, depend on SpringDependencies module. That will transitively pull all Spring dependencies.

There is no way, and there should be none. You should only use the jars you really need, no need for all spring jars. For 2.x there used to be a spring.jar but in every project I've seen that used, it caused version collision problems.
If you are using any subprojects from Spring, watch it that sometimes they still pull Spring 2.5 (e.g. Spring Batch and I think Spring Web Flow as well), in this case you should use the exclusions tag in your pom.xml.
Not the most convenient to assemble it the first time, but then you can reuse it in your other projects.

There's no wildcards whatsoever in the Maven dependencies, and there's no artifact that gathers all Spring modules anymore. Does your project really use all Spring modules anyway?

There was such an all-in-one module in Spring 2.x, however it didn't survive the module refactoring happened in Spring 3.x. So, the answer is 'No'.

Spring-context internally resolves other dependencies. Please find below the dependency tree.
[INFO] com.example:springpractice:jar:1.0-SNAPSHOT
[INFO] \- org.springframework:spring-context:jar:4.3.7.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.3.7.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:4.3.7.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.3.7.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] \- org.springframework:spring-expression:jar:4.3.7.RELEASE:compile

Related

Maven Spring boot dependency vs Maven Spring dependency

What is the difference between the way I declare the two dependency?
My project is a spring boot project...
This one I downloaded from Spring Initializer:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-ldap</artifactId>
</dependency>
This one is from mvnrepository.com:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
Update, this article shows a third way:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
The first one is a Spring Boot starter. According to the documentation:
Starters are a set of convenient dependency descriptors that you can include in your application. You get a one-stop shop for all the Spring and related technologies that you need without having to hunt through sample code and copy-paste loads of dependency descriptors.
The pom.xml of spring-boot-starter-data-ldap contains the following dependency definitions:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-ldap</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
The second one: spring-security-ldap is the artifact present in maven central, corresponding to the Spring LDAP project.

Apache CXF and Spring dependencies conflict exception

I want to integrate CXF and Spring for a simple JAX-WS. Below is the maven pom file.
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</dependency>
</dependencies>
When I run the jetty using maven command. It had some exception like this:
spring java.lang.NoSuchMethodError: org.springframework.core.convert.converter.ConverterRegistry.addConverter(Ljava/lang/Class;Ljava/lang/Class;Lorg/springframework/core/convert/converter/Converter;)V
It seems the problem is CXF and Spring dependencies problems. When I go to the target folders and find out there are two version of Spring with the version I specified and the version CXF depend on. 3.0.7?
If I change the spring version to the lower one and it works.
I just wondering are there any way to solve this if I still want to use the latest version of Spring?
I think I find out the reason. I need also to put spring-core as maven dependency. Because the converter in the exception are in the core dependency.
So when the maven jetty run, there are two version of spring, spring-core is using 3.0.7 which is with CXF, and the other are 3.2.3 which is I specified.
I need to keep consistent with spring version in the project.

Unable to find dependency org.springframework.spring-library on maven central

Referring to site :
http://ebr.springsource.com/repository/app/library/version/detail;jsessionid=DAA99420F19DE8A30A9A869C347ADB8E.jvm1?name=org.springframework.spring&version=3.2.2.RELEASE
the maven dependency :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.spring-library</artifactId>
<type>libd</type>
<version>3.2.2.RELEASE</version>
</dependency>
does not seem to be available :
Here is the request :
http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22org.springframework.spring-library%22
Should'nt this repository be available on Maven ?
You may need to add Spring specific repositories in your pom.xml
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>EBR Spring Release Repository</name>
<url>http:// repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>EBR External Release Repository</name>
<url>http:// repository.springsource.com/maven/bundles/external</url>
</repository>
And as mardavi said the maven co-ordinates for Spring also looks wrong.
This link might help
I guess
org.springframework.spring-library
is a placeholder for a generic artifactId. In my knowledge there is no spring-library artifact, but several one. If instead of spring-library you write spring-core, spring-web etc then it will work.
I have seen this same issue and solved it. I think it's a bundle of all the spring libraries for a specific version. Why it's not found I cannot say. By replacing it with the individual dependencies I was able to get my code base to work.
Dependencies found here: http://spring.io/blog/2009/12/02/obtaining-spring-3-artifacts-with-maven/
<!-- Shared version number properties -->
<properties>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>
<!--
Core utilities used by other modules.
Define this if you use Spring Utility APIs (org.springframework.core.*/org.springframework.util.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Expression Language (depends on spring-core)
Define this if you use Spring Expression APIs (org.springframework.expression.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Bean Factory and JavaBeans utilities (depends on spring-core)
Define this if you use Spring Bean APIs (org.springframework.beans.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Aspect Oriented Programming (AOP) Framework (depends on spring-core, spring-beans)
Define this if you use Spring AOP APIs (org.springframework.aop.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Application Context (depends on spring-core, spring-expression, spring-aop, spring-beans)
This is the central artifact for Spring's Dependency Injection Container and is generally always defined
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Various Application Context utilities, including EhCache, JavaMail, Quartz, and Freemarker integration
Define this if you need any of these integrations
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Transaction Management Abstraction (depends on spring-core, spring-beans, spring-aop, spring-context)
Define this if you use Spring Transactions or DAO Exception Hierarchy
(org.springframework.transaction.*/org.springframework.dao.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx)
Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and iBatis.
(depends on spring-core, spring-beans, spring-context, spring-tx)
Define this if you need ORM (org.springframework.orm.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, Castor, XStream, and XML Beans.
(depends on spring-core, spring-beans, spring-context)
Define this if you need OXM (org.springframework.oxm.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Web application development utilities applicable to both Servlet and Portlet Environments
(depends on spring-core, spring-beans, spring-context)
Define this if you use Spring MVC, or wish to use Struts, JSF, or another web framework with Spring (org.springframework.web.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Spring MVC for Servlet Environments (depends on spring-core, spring-beans, spring-context, spring-web)
Define this if you use Spring MVC with a Servlet Container such as Apache Tomcat (org.springframework.web.servlet.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Spring MVC for Portlet Environments (depends on spring-core, spring-beans, spring-context, spring-web)
Define this if you use Spring MVC with a Portlet Container (org.springframework.web.portlet.*)
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--
Support for testing Spring applications with tools such as JUnit and TestNG
This artifact is generally always defined with a 'test' scope for the integration testing framework and unit testing stubs
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>

Spring 3 Hibernate JPA 2.0 Maven and value '2.0' error

Im trying to create application from scratch. In new maven project i add a lot of dependencies, create persistence.xml, application.xml and modify web.xml. Also introduce some entities and controllers. Next im trying to run it on jetty using mvn jetty:run, and then i got this exception :
org.xml.sax.SAXParseException: cvc-complex-type.3.1: Value '2.0' of attribute 'version' of element 'persistence' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '1.0'.
After googling i learnd that it might be because i have several realization of JPA in class path, and one of them probably is 1.0. But i cant understand, where it can be, because i use only latest version of hibernate entiry manager, and explicity dont add any other realization. Where there may be a bug? Can problem be because i added many spring dependencies?
<dependencies>
<!-- 1111111 -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- 2222222 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.0.Final</version>
</dependency>
<!-- 33333333 -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.0.0</version>
</dependency>
<!-- 4444444 -->
<!--Core utilities used by other modules. Define this if you use Spring Utility APIs (org.springframework.core.*/org.springframework.util.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Expression Language (depends on spring-core) Define this if you use Spring Expression APIs (org.springframework.expression.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Bean Factory and JavaBeans utilities (depends on spring-core) Define this if you use Spring Bean APIs (org.springframework.beans.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Aspect Oriented Programming (AOP) Framework (depends on spring-core, spring-beans) Define this if you use Spring AOP APIs (org.springframework.aop.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Application Context (depends on spring-core, spring-expression, spring-aop, spring-beans) This is the central artifact for Spring's Dependency Injection Container and is generally always Defined-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Various Application Context utilities, including EhCache, JavaMail, Quartz, and Freemarker integration Define this if you need any of these integrations-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Transaction Management Abstraction (depends on spring-core, spring-beans, spring-aop, spring-context) Define this if you use Spring Transactions or DAO Exception Hierarchy(org.springframework.transaction.*/org.springframework.dao.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and iBatis.(depends on spring-core, spring-beans, spring-context, spring-tx) Define this if you need ORM (org.springframework.orm.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, Castor, XStream, and XML Beans.(depends on spring-core, spring-beans, spring-context) Define this if you need OXM (org.springframework.oxm.*)
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency> -->
<!--Web application development utilities applicable to both Servlet and Portlet Environments(depends on spring-core, spring-beans, spring-context) Define this if you use Spring MVC, or wish to use Struts, JSF, or another web framework with Spring (org.springframework.web.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Spring MVC for Servlet Environments (depends on spring-core, spring-beans, spring-context, spring-web) Define this if you use Spring MVC with a Servlet Container such as Apache Tomcat (org.springframework.web.servlet.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Spring MVC for Portlet Environments (depends on spring-core, spring-beans, spring-context, spring-web) Define this if you use Spring MVC with a Portlet Container (org.springframework.web.portlet.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Support for testing Spring applications with tools such as JUnit and TestNGThis artifact is generally always Defined with a 'test' scope for the integration testing framework and unit testing stubs-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<!-- 55555555 -->
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
and my persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="units" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.password" value=""/>
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:."/>
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
${org.springframework.version} = 3.0.0.RELEASE
if something else needed - i can provide
p.s. sorry for english
IMHO your POM, its dependencies and the persistence.xml file looks OK. I can't see any reason why JPA 1.0 somehow have precedence over JPA 2.0, at least on your application side. Thus, you should check the other side, that is your Jetty instance you deploy the application to. Ensure that its libs (that are provided to the application classpath) don't contain JPA 1.0 (its realization, like old Hibernate version), because then JPA 1.0 has precedence. I really don't see any other reason but old JPA implementation in classpath.
Alternatively, just try to download vanilla Tomcat, unpack it and deploy your app how it is (WAR file). This will ensure you that the application is OK and this is a container's problem.

<mvc:resources> type not resolved

I am trying to build the mvc-showcase example available here link.
But i am getting the below error:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'resources'.
Source code of servlet-context.xml is
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven conversion-service="conversionService" />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<!-- Imports user-defined #Controller beans that process client requests -->
<beans:import resource="controllers.xml" />
<!-- Only needed because we install custom converters to support the examples in the org.springframewok.samples.mvc.convert package -->
<beans:bean id="conversionService" class="org.springframework.samples.mvc.convert.CustomConversionServiceFactoryBean" />
<!-- Only needed because we require fileupload in the org.springframework.samples.mvc.fileupload package -->
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
</beans:beans>
NOTE: I am using Eclipse IDE and i am using spring 3.0.4 version(because i am using the same pom.xml given in the project link)
The tag is a new feature in Spring Framework 3.0.4, so check your spring version.
Cheers
I got the same problem with the tag . The problem is your spring version as #Drolyk sad are available in version 3.0.4 or later, so i will give you my dependencies and I am sure that if you use them u will solve this problem:
<!-- BEGINING OF FULL SPRING 3 DEPENDENCES -->
<!-- Shared version number properties -->
<properties>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>
<!--Core utilities used by other modules.
Define this if you use Spring Utility APIs (org.springframework.core.*/org.springframework.util.*)-->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Expression Language (depends on spring-core)
Define this if you use Spring Expression APIs (org.springframework.expression.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Bean Factory and JavaBeans utilities (depends on spring-core)
Define this if you use Spring Bean APIs (org.springframework.beans.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Aspect Oriented Programming (AOP) Framework (depends on spring-core, spring-beans)
Define this if you use Spring AOP APIs (org.springframework.aop.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Application Context (depends on spring-core, spring-expression, spring-aop, spring-beans)
This is the central artifact for Spring's Dependency Injection Container and is generally always
Defined-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Various Application Context utilities, including EhCache, JavaMail, Quartz, and Freemarker integration
Define this if you need any of these integrations-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Transaction Management Abstraction (depends on spring-core, spring-beans, spring-aop, spring-context)
Define this if you use Spring Transactions or DAO Exception Hierarchy(org.springframework.transaction.*/org.springframework.dao.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx)
Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and iBatis.(depends on spring-core, spring-beans, spring-context, spring-tx)
Define this if you need ORM (org.springframework.orm.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, Castor, XStream, and XML Beans.(depends on spring-core, spring-beans, spring-context)
Define this if you need OXM (org.springframework.oxm.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Web application development utilities applicable to both Servlet and Portlet Environments(depends on spring-core, spring-beans, spring-context)
Define this if you use Spring MVC, or wish to use Struts, JSF, or another web framework with Spring (org.springframework.web.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Spring MVC for Servlet Environments (depends on spring-core, spring-beans, spring-context, spring-web)
Define this if you use Spring MVC with a Servlet Container such as Apache Tomcat (org.springframework.web.servlet.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Spring MVC for Portlet Environments (depends on spring-core, spring-beans, spring-context, spring-web)
Define this if you use Spring MVC with a Portlet Container (org.springframework.web.portlet.*)-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc-portlet</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!--Support for testing Spring applications with tools such as JUnit and TestNGThis artifact is generally always
Defined with a 'test' scope for the integration testing framework and unit testing stubs-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<!-- Begining of Java Standard Tag Libraries -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<scope>runtime</scope>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>c</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
<type>tld</type>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>fmt</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
<type>tld</type>
</dependency>
<!-- End of Java Standard Tag Libraries -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- END OF FULL SPRING 3 DEPENDENCES -->
Unfortunately I cannot seem to get it going in Eclipse 3.6. I have however got it going in Spring Tool Suite v2.5.0.M3 (http://www.springsource.com/products/springsource-google-download) - if you check their XML Catalog their are literally dozens of entries which may negate the value of using vanilla Eclipse over STS. If you are in the process of learning Spring and are confused by the lack of getting started documentation you may want to try Spring Roo which I personally use to get a Spring MVC project going - it can be disabled afterwards if you prefer.
Check out the MVC Showcase video (http://s3.springsource.org/MVC/mvc-showcase-screencast.mov) which shows loading the MVC Showcase into STS. Please note that the only version that appears to fix the Eclipse errors (runtime is fine everywhere) is v2.5.0.M3 - just make sure that you checkout the showcase code into a new workspace for that STS version.
Hope this helps.
It's not related to your error, but what I am missing is <context:component-scan base-package="..."/> in your configuration.
And prefer to use <mvc:annotation-driven .../>. It get not mix up with <tx:annotation-driven .../> or <task:annotation-driven />.

Resources