Spring core maven dependency

Spring core maven dependency DEFAULT

Maven dependency for whole org.springframework

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):

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:

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:

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.

Sours: https://stackoverflow.com/questions//maven-dependency-for-whole-org-springframework
<?xml version="" encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/"xsi:schemaLocation="http://maven.apache.org/POM/ http://maven.apache.org/maven-v4_0_0.xsd"xmlns:xsi="http://www.w3.org//XMLSchema-instance"> <modelVersion></modelVersion> <groupId>org.springframework.samples.spring</groupId> <artifactId>spring-utility</artifactId> <version>CI-SNAPSHOT</version> <packaging>jar</packaging> <name>Spring Utility</name> <url>http://www.springframework.org</url> <description><![CDATA[ This project is a minimal jar utility with Spring configuration.]]> </description> <properties> <maven.test.failure.ignore>true</maven.test.failure.ignore> <spring.framework.version>RELEASE</spring.framework.version> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version></version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.framework.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.framework.version}</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over-slf4j</artifactId> <version></version> <scope>runtime</scope> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version></version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source></source> <target></target> </configuration> </plugin> </plugins> </build></project>
Sours: https://github.com/lalyos/spring-core-maven/blob/master/pom.xml
  1. De anza nursing program
  2. 2018 silverado battery replacement
  3. Dell inspiron 660 ram upgrade
  4. Labradoodle puppies fort wayne indiana

Programmatic Ponderings

Integrate the Spring Framework into your next Eclipse-based project using Apache Maven. Learn how to install, configure, and integrate these three leading Java development tools. All source code for this post is available on GitHub.

Introduction

Although there is a growing adoption of Java EE 6 and CDI in recent years, Spring is still a well-entrenched, open-source framework for professional Java development. According to GoPivotal’s website, “The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications. Spring focuses on the ‘plumbing’ of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.”

Similar to Spring in terms of wide-spread adoption, Eclipse is leading Java IDE, competing with Oracle’s NetBeans and JetBrain’s IntelliJ. The use of Spring within Eclipse is very common. In the following post, I will demonstrate the ease of integrating Spring with Eclipse, using Maven.

Maven is a marketed as a project management tool, centralizing a project&#;s build, reporting and documentation. Conveniently, Maven is tightly integrated with Eclipse. We will use Maven for one of its best known features, dependency management. Maven will take care of downloading and managing the required Spring artifacts into our Eclipse-based project.

Note there are alternatives to integrating Spring into Eclipse, using Maven. You can download and add the Spring artifacts yourself, or go full-bore with GoPivotal’s Spring Tool Suite (STS). According to their website, STS is an Eclipse-based development environment, customized for developing Spring applications.

The steps covered in this post are as follows:

  1. Download and install Maven
  2. Download and install the Eclipse IDE
  3. Linking the installed version of Maven to Eclipse
  4. Creating a new sample Maven Project
  5. Adding Spring dependencies to the project
  6. Demonstrate a simple example of Spring Beans and ApplicationContext
  7. Modify the project to allow execution from an external command prompt

Installing Maven

Installing Maven is simple process, requiring minimal configuration:

  1. Download the latest version of Maven from the Apache Maven Project website. At the time of this post, Maven is at version
  2. Assuming you are Windows, unzip the ‘apache-maven’ folder and place in your ‘Program Files’ directory.
  3. Add the path to Maven’s bin directory to your system’s ‘PATH’ Environmental Variable.
Adding Maven bin Directory to PATH Environmental Variable

Adding Maven bin Directory to PATH Environmental Variable

We can test our Maven installation by opening a new Command Prompt and issuing the ‘mvn -version’ command. The command should display the installed version of Maven, Maven home directory, and other required variables, like your machine’s current version of Java and its location. To learn other Maven commands, try ‘mvn -help’.

Checking Maven is Installed Correctly

Checking Maven is Installed Correctly

Installing Eclipse IDE

Installing Eclipse is even easier:

  1. Download the latest version of Eclipse from The Eclipse Foundation website. There are several versions of Eclipse available. I chose ‘Eclipse IDE for Java EE Developers’, currently Kepler Service Release 1.
  2. Similar to Maven, unzip the ‘eclipse’ folder and place in your ‘Program Files’ directory.
  3. For ease of access, I recommend pinning the main eclispe.exe file to your Start Menu.
Downloading Eclipse IDE for Java EE Developers

Downloading Eclipse IDE for Java EE Developers

Linking Maven to Eclipse

The latest version of Eclipse comes pre-loaded with the ‘M2E – Maven Integration for Eclipse’ plug-in. There is no additional software installs required to use Maven from within Eclipse. Eclipse also includes an embedded runtime version of Maven (currently ). According to the Eclipse website wiki, the M2E plug-in uses the embedded runtime version of Maven when running Maven builder, importing projects and updating project configuration.

Latest Version of Eclipse Kepler SR1 with M2E Installed

Latest Version of Eclipse Kepler SR1 with M2E Installed

Although Eclipse contains an embedded version of Maven, we can configure M2E to use our own external Maven installation when launching Maven using Run as… -> M2 Maven actions. To configure Maven to use the version of Maven we just installed:

  1. Go to Windows -> Preferences -> Maven -> Installations window. Note the embedded version of Maven is the only one listed and active.
  2. Click Add… and select the Maven folder we installed in your Program Files directory. Click OK.
  3. Check the box for new installation we just added instead of the embedded version. Click OK.
Adding Installed Version of Maven to Eclipse

Adding Installed Version of Maven to Eclipse

Adding Installed Version of Maven to Eclipse

Adding Installed Version of Maven to Eclipse

Adding Installed Version of Maven to Eclipse

Adding Installed Version of Maven to Eclipse

Sample Maven Project

To show how to integrate Spring into a project using Maven, we will create a Maven Project in Eclipse using the Maven Quickstart Archetype template. The basic project will show the use of Spring Beans and an ApplicationContext IoC container. On a scale of 1 to 10, with 10 being the most complex Spring example, this project is barely a 1! However, it will demonstrate that Spring is working in Eclipse, with minimal effort thanks to Maven.

To create the project:

  1. File -> New Project -> Other…
  2. Search on ‘maven’ in the Wizards text box and select ‘Maven Project’.
  3. Select the Maven Quickstart Archetype.
  4. Specify the Archetype parameters.
Creating a New Maven Project - Using Wizard

Creating a New Maven Project &#; Using Wizard

Creating a New Maven Project - Project Location

Creating a New Maven Project &#; Project Location

Creating a New Maven Project - Choosing Archetype

Creating a New Maven Project &#; Choosing Archetype

Creating a New Maven Project - Archetype Parameters

Creating a New Maven Project &#; Archetype Parameters

Spring Dependencies

Once the Maven Quickstart project is created, we will add the required Spring dependencies using Maven:

  1. Open the Maven Project Object Model (POM) file and select the Dependencies tab.
  2. Use the The Central Repository website to find the Dependency Information for spring-core and Spring-context artifacts (jar files).
  3. Add… both Spring Dependencies to the pom.xml file.
  4. Right-click on the project and click Maven -> Update Project…
Adding Spring Dependencies to pom.xml - Dependencies Tab

Adding Spring Dependencies to pom.xml &#; Dependencies Tab

Adding Spring Dependencies to pom.xml - Artifact Details for spring-core

Adding Spring Dependencies to pom.xml &#; Artifact Details for spring-core

Adding Spring Dependencies to pom.xml - Adding spring-context

Adding Spring Dependencies to pom.xml &#; Adding spring-context

Adding Spring Dependencies to pom.xml - Spring Dependencies Added

Adding Spring Dependencies to pom.xml &#; Spring Dependencies Added

Adding Spring Dependencies to pom.xml - Dependencies Added to Project

Adding Spring Dependencies to pom.xml &#; Dependencies Added to Project

We now have a Maven-managed Eclipse project with our Spring dependencies included. Note the root of the file paths to the jar files in the Maven Dependencies project folder is the location of our Maven Repository. This is where all the dependent artifacts (jar files) are stored. In my case, the root is ‘C:\Users\{user}\.m2\repository’. The repository location is stored in Eclipse&#;s Maven User Setting&#;s Preferences (see below).

Project Object Model File (pom.xml):

<projectxmlns="http://maven.apache.org/POM/"xmlns:xsi="http://www.w3.org//XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/http://maven.apache.org/xsd/mavenxsd">
<modelVersion></modelVersion>
<groupId>com.blogpost.maven</groupId>
<artifactId>maven-spring</artifactId>
<version>SNAPSHOT</version>
<packaging>jar</packaging>
<name>maven-spring</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version></version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
<description>Project for blog post about the use of Spring with Eclipse and Maven.</description>
</project>
Location of Local Maven Repository

Local Maven Repository Location

Sample Code

Next add the supplied Code to the project. We will add two new java classes and a Spring configuration file. We will replace the contents of main App class with our sample code. Steps are as follows:

  1. Add the supplied Vehicle.java and MaintainVehicle.java class files to the project, in the same classpath as the App.java class.
  2. Add the supplied Beans.xml Spring configuration file to the project at the ‘src/main/java’ folder.
  3. Open the App.java class file and replace the contents with the supplied App.java class file.

The sample Spring application is based on vehicles. There are three Spring Beans defined in the xml-based Spring configuration file, representing three different vehicles. The main App class uses an ApplicationContext IoC Container to instantiate three Vehicle POJOs from the Spring Beans defined in the Beans.xml Spring configuration. The main class then instantiates an instance of the MaintainVehicle class, passes in the Vehicle objects and calls MaintainVehicle’s two methods.

Location of New Files in Project Explorer

Location of New Files in Project Explorer

Spring Configuration File (Beans.xml):

<?xml version="" encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org//XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beansxsd">
<beanid="vehicle1"class="com.blogpost.maven.maven_spring.Vehicle">
<propertyname="make"value="Mercedes-Benz" />
<propertyname="model"value="ML" />
<propertyname="year"value="" />
<propertyname="color"value="Silver" />
<propertyname="type"value="SUV" />
</bean>
<beanid="vehicle2"class="com.blogpost.maven.maven_spring.Vehicle">
<propertyname="make"value="Jaguar" />
<propertyname="model"value="F-Type" />
<propertyname="year"value="" />
<propertyname="color"value="Red" />
<propertyname="type"value="Convertible" />
</bean>
<beanid="vehicle3"class="com.blogpost.maven.maven_spring.Vehicle">
<propertyname="make"value="Suzuki" />
<propertyname="model"value="SVF " />
<propertyname="year"value="" />
<propertyname="color"value="Black" />
<propertyname="type"value="Motorcycle" />
</bean>
</beans>

Main Method Class (App.java)

packagecom.blogpost.maven.maven_spring;
importorg.springframework.context.ApplicationContext;
importorg.springframework.context.support.ClassPathXmlApplicationContext;
publicclassApp {
publicstaticvoidmain(String[] args) {
@SuppressWarnings("resource")
ApplicationContext context =newClassPathXmlApplicationContext(
"Beans.xml");
MaintainVehicle maintain =newMaintainVehicle();
// vehicle1 bean
Vehicle obj1 = (Vehicle) context.getBean("vehicle1");
System.out.printf("I drive a %s.\n", obj1.getLongDescription());
System.out.printf("Is my %s tuned up? %s\n",
obj1.getShortDescription(), obj1.getServiced());
maintain.serviceVehicle(obj1);
System.out.printf("Is my %s tuned up, yet? %s\n\n", obj1.getMake(),
obj1.getServiced());
// vehicle2 bean
Vehicle obj2 = (Vehicle) context.getBean("vehicle2");
System.out.printf("My wife drives a %s.\n", obj2.getLongDescription());
System.out.printf("Is her %s clean? %s\n", obj2.getShortDescription(),
obj2.getWashed());
maintain.washVehicle(obj2);
System.out.printf("Is her %s clean, now? %s\n\n", obj2.getMake(),
obj2.getWashed());
// vehicle3 bean
Vehicle obj3 = (Vehicle) context.getBean("vehicle3");
System.out.printf("Our son drives his %s too fast!\n", obj3.getType()
.toLowerCase());
}
}

Running the Application

If successful, the application will output a series of messages to the Console. The first few messages in red are Spring-related messages, signifying Spring is working. The next messages in black are output by the application. The messages show that the three Spring Beans are successfully instantiated and passed to the MaintainVehicle object, where it&#;s methods were called. If the application would only buy me that Silver Mercedes!

Successful Console Output of Java Application

Successful Console Output of Java Application

Running the Application from a Command Prompt

All the source code for this project is available on GitHub. Note the pom.xml contains a some extra configuration information not shown above. The extra configuration information is not necessary for running the application from within Eclipse. However, if you want to run the application from an external Command Prompt, you will need the added configuration. This extra configuration ensures that the project is correctly packaged into a jar file, with all the necessary dependencies to run. Extra configuration includes an additional logging dependency, a resource reference to the Spring configuration file, one additional property, and three maven plug-in references for compiling and packaging the jar.

To run the java application from an external Command Prompt:

  1. Open a new Command Prompt
  2. Change current directory to the project&#;s root directory (local GitHub repository in my case)
  3. Run a &#;mvn compile&#; command
  4. Run a &#;mvn package&#; command (downloads dependencies and creates jar)
  5. Change the current directory to the project&#;s target sub-directory
  6. Run a &#;dir&#; command. You should see the project&#;s jar file
  7. Run a &#;java -jar {name-of-jar-file.jar}&#; command.

You should see the same messages output in Eclipse, earlier.

Running Application from External Command Prompt

Running Application from External Command Prompt

Like this:

artifact, CDI, Dependencies, Eclipse, Git, IoC, Java, JAVA EE, Maven, Oracle, Spring, Spring Bean

This entry was posted on October 21, , pm and is filed under Enterprise Software Development, Java Development, Software Development. You can follow any responses to this entry through RSS You can leave a response, or trackback from your own site.

Sours: https://programmaticponderings.com//10/21/spring-integration-with-eclipse-using-maven/
Spring Core Hello World Example using Eclipse Maven

Maven Repository Spring

Maven Repository Spring

Introduction to Maven Repository Spring

Maven repository provides us with all the dependencies that we need to have in our project. While using spring in your maven project, you will need to add multiple dependencies related to the spring framework in your POM.xml file depending on what part of spring you are using. Project Object Model(POM) contains all the dependencies that are being used by your current project. Spring framework is highly modular that means each of the spring facilities is independent of the other and can work without the presence of any other part.

Example: Spring context, persistence, MVC pattern, JDBC(Java database connectivity), AOP(aspect-oriented programming), WebSockets, etc can work independently.

Maven Repository Spring Related Dependencies

We will see the most commonly used spring related dependencies in the below section. Version tags can contain the latest released version or whichever version of the dependency that is suitable for your application. is the latest version as of now when this article was being written. Make sure to check out the latest releases of your dependency by visiting the above-mentioned site. org.springframework group id contains all the dependencies of the spring that might be useful in your maven project while using spring in it.

1. Basic spring usage

When you use the core spring facilities such as aspect-oriented programming, java beans, and spring expression language you will need to mention the dependency of spring-context. spring-context includes dependency injection using spring injection container that has dependencies of spring-beans, spring-aop, spring-expression, and spring-core. This can be simply included in your pom.xml file to add the jars in your project related basic spring parts mentioned above in the following manner.

Code:

2. Spring persistence Usage

You can make the use of spring persistence features such as hibernate and Java persistence API(JPA), Java database connectivity(JDBC) and spring transaction functionalities by adding the spring-orm dependency that has spring-tx and spring-jdbc dependencies. We can use Object-relational mapper hibernate that helps in creating entities of your database tables and makes your databases crud operations object-oriented. Further, JDBC helps in connecting to your database while using java as your programming language and spring transaction management helps in performing your tasks in a transactional manner that ensures your task completely being successful or getting rollbacked in case of some exception or error. Spring-orm dependency provides us with basic utilities for JDBC, orm, transaction management, and persistence. All this can be included in the following manner by adding this dependency tag:

Code:

3. MVC pattern in spring

You can make the use of the most reliable framework of all times i.e Model-View-Controller pattern in spring applications when you are trying to create web applications or servlet-based applications by adding spring-webmvc dependency along with the above mentioned basic dependencies in the following manner:

Code:

spring-webmvc has built-in spring-web dependency in itself. Hence, you don’t need to mention it explicitly. Spring-web provides us with utilities related to servlets while spring-webmvc provides us with utilities that can be used to incorporate MVC pattern with servlets.

4. Spring Security usage

We can make the use of access control functionalities and authentication by adding the spring-security-core dependency in your pom.xml file. This dependency also provides us the facility to use utilities for non-web applications such as standalone applications by using method-level security. Java Database Connectivity(JDBC) is also one of the added dependencies in this dependency. This can be added by using the following dependency tag:

Code:

5. Spring-test usage

We can include a test framework of spring by adding spring-test dependency in our pom.xml file. In all the versions of spring and above the MVC test project of spring is included in its core test project. Hence, it is enough to add just spring-test dependency. This can be added by using the following dependency tag:

Code:

6. Milestones usage

Whenever you mention the RELEASE in your version tag it by defaults refer to the spring that has been hosted on the central repository of maven. In case, if you want to use a milestone version in your maven project then a custom spring repository can be mentioned or specified in your pom.xml file. This can be done by adding the following repository tag in your pom.xml:

Code:

Note: That in such cases, you will first have to define these repositories in pom.xml and then you can proceed with adding your dependency in dependencies tag after this specifying your version of custom repository for the milestone.

7. Snapshot usage

In case if you are using snapshots in your maven project, then you will have to mention the custom repository in your pom.xml file specifying the snapshot path and URL. This repository can be added by using the following format:

Code:

Note: That in this case too, you will have to mention the version tag of your dependencies according to the snapshot version that you have hosted and are referring to.

Conclusion

We can add the dependencies in our pom.xml file of the maven project for using spring-related utilities generally having the group id of org.springframework. Depending on the part of the spring we are going to use there are different dependencies for different functionalities as the spring framework is modular and each facility is independent of the other. Above mentioned are just some of the dependencies available. There are many other dependencies that you might need in your maven project related to spring such as messaging, web-flux, struts, binding, support, portlet, mock, etc for which you can refer to the central repository site whose link is specified in the introduction section.

Recommended Articles

This is a guide to Maven Repository Spring. Here we an introduction, top 7 Spring Related Dependencies in detail explanation. You can also go through our other related articles to learn more &#;

  1. Maven Repository
  2. Maven Plugins
  3. Maven POM File
  4. Maven Life Cycle
Sours: https://www.educba.com/maven-repository-spring/

Core maven dependency spring

Maven Repository - POM file for Spring spring-core RELEASE RELEASE

Summary

Spring Core.

Declaration

Here is the list of declaration for spring-core. If you use Maven you can use the following code to add the dependency for this POM file.

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>RELEASE</version> </dependency>

If you think this Maven repository POM file listing for spring-core is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

License

Name:The Apache Software License, Version
URL: http://www.apache.org/licenses/LICENSEtxt.

Depends on

The spring-coreRELEASE has 4 dependencies.The most popular ones are listed in the following table along with their categories and number of artifacts depending on them.

CategoryArtifactDepended By Count
Logcommons-logging
Commons Logging is a thin adapter allowing configurable bridging to other, well known logging systems.
Loglog4j
Apache Log4j
Consolejopt-simple
A Java library for parsing command line options
39
AOPaspectjweaver
The AspectJ weaver introduces advices to java classes
61

Depended by

The following table lists the most popular artifacts which are depending on spring-coreRELEASE. Their categories and depend by count are also listed.

Packages

The following packages are defined in the spring-coreRELEASE.jar

org.springframework.asm org.springframework.asm.util org.springframework.cglib org.springframework.cglib.beans org.springframework.cglib.core org.springframework.cglib.proxy org.springframework.cglib.reflect org.springframework.cglib.transform org.springframework.cglib.transform.impl org.springframework.cglib.util org.springframework.core org.springframework.core.annotation org.springframework.core.convert org.springframework.core.convert.converter org.springframework.core.convert.support org.springframework.core.env org.springframework.core.io org.springframework.core.io.support org.springframework.core.serializer org.springframework.core.serializer.support org.springframework.core.style org.springframework.core.task org.springframework.core.task.support org.springframework.core.type org.springframework.core.type.classreading org.springframework.core.type.filter org.springframework.objenesis org.springframework.objenesis.instantiator org.springframework.objenesis.instantiator.android org.springframework.objenesis.instantiator.basic org.springframework.objenesis.instantiator.gcj org.springframework.objenesis.instantiator.jrockit org.springframework.objenesis.instantiator.perc org.springframework.objenesis.instantiator.sun org.springframework.objenesis.strategy org.springframework.util org.springframework.util.comparator org.springframework.util.concurrent org.springframework.util.xml

POM File Source

Here is the content of the POM file.

<?xml version="" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/POM/ http://maven.apache.org/xsd/mavenxsd" xmlns="http://maven.apache.org/POM/" xmlns:xsi="http://www.w3.org//XMLSchema-instance"> <modelVersion></modelVersion> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>RELEASE</version> <name>Spring Core</name> <description>Spring Core</description> <url>https://github.com/spring-projects/spring-framework</url> <organization> <name>Spring IO</name> <url>http://projects.spring.io/spring-framework</url> </organization> <licenses> <license> <name>The Apache Software License, Version </name> <url>http://www.apache.org/licenses/LICENSEtxt</url> <distribution>repo</distribution> </license> </licenses> <issueManagement> <system>Jira</system> <url>https://jira.springsource.org/browse/SPR</url> </issueManagement> <scm> <connection>scm:git:git://github.com/spring-projects/spring-framework</connection> <developerConnection>scm:git:git://github.com/spring-projects/spring-framework</developerConnection> <url>https://github.com/spring-projects/spring-framework</url> </scm> <dependencies> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version></version> <scope>compile</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version></version> <scope>compile</scope> <optional>true</optional> </dependency> <dependency> <groupId>net.sf.jopt-simple</groupId> <artifactId>jopt-simple</artifactId> <version></version> <scope>compile</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version></version> <scope>compile</scope> <optional>true</optional> </dependency> </dependencies> </project>
Sours: http://www.java2s.com/Open-Source/Maven_Repository/Spring/spring-core/spring_core_4_0_1_RELEASE.htm
Introduction to Maven - Theory

Table of Contents

  1. Overview
  2. Basic Spring Dependencies with Maven
  3. Spring Persistence with Maven
  4. Spring MVC with Maven
  5. Spring Security with Maven
  6. Spring Test with Maven
  7. Using Milestones
  8. Using Snapshots
  9. Conclusion

1. Overview

This tutorial illustrates how to set up the Spring dependencies via Maven. The latest Spring releases can be found on Maven Central.

2. Basic Spring Dependencies With Maven

Spring is designed to be highly modular &#; using one part of Spring should not and does not require another. For example, the basic Spring Context can be without the Persistence or the MVC Spring libraries.

Let's start with a fundamental Maven setup which will only use the spring-context dependency:

This dependency &#; spring-context &#; defines the actual Spring Injection Container and has a small number of dependencies: spring-core, spring-expression, spring-aop, and spring-beans. These augment the container by enabling support for some of the core Spring technologies: the Core Spring utilities, the Spring Expression Language (SpEL), the Aspect-Oriented Programming support and the JavaBeans mechanism.

Note we're defining the dependency in the runtime scope &#; this will make sure that there are no compile-time dependencies on any Spring specific APIs. For more advanced use cases, the runtime scope may be removed from some selected Spring dependencies, but for simpler projects, there is no need to compile against Spring to make full use of the framework.

Also, note that JDK 8 is the minimum Java version required for Spring It also supports JDK 11 as the current LTS branch and JDK 13 as the latest OpenJDK release.

3. Spring Persistence With Maven

Let's now look at the persistence Spring dependencies &#; mainly spring-orm:

This comes with Hibernate and JPA support &#; such as HibernateTemplate and JpaTemplate &#; as well as a few additional, persistence related dependencies: spring-jdbc and spring-tx.

The JDBC Data Access library defines the Spring JDBC support as well as the JdbcTemplate, and spring-tx represents the extremely flexible Transaction Management Abstraction.

4. Spring MVC With Maven

To use the Spring Web and Servlet support, two dependencies need to be included in the pom, again in addition to the core dependencies from above:

The spring-web dependency contains common web specific utilities for both Servlet and Portlet environments, while spring-webmvc enables the MVC support for Servlet environments.

Since spring-webmvc has spring-web as a dependency, explicitly defining spring-web is not required when using spring-webmvc.

Starting Spring , for the reactive-stack web framework support, we can add the dependency for Spring WebFlux:

5. Spring Security With Maven

Security Maven dependencies are discussed in depth in the Spring Security with Maven article.

6. Spring Test With Maven

The Spring Test Framework can be included in the project via the following dependency:

With Spring 5, we can perform concurrent test execution as well.

7. Using Milestones

The release version of Spring is hosted on Maven Central. However, if a project needs to use milestone versions, then a custom Spring repository needs to be added to the pom:

Once this repository has been defined, the project can define dependencies such as:

8. Using Snapshots

Similar to milestones, snapshots are hosted in a custom repository:

Once the SNAPSHOT repository is enabled in the pom.xml, the following dependencies can be referenced:

As well as &#; for 5.x:

9. Conclusion

This article discusses the practical details of using Spring with Maven. The Maven dependencies presented here are of course some of the major ones, and several others may be worth mentioning and have not yet made the cut. Nevertheless, this should be a good starting point for using Spring in a project.

Spring bottom

Get started with Spring 5 and Spring Boot 2, through the Learn Spring course:

>> THE COURSE

Sours: https://www.baeldung.com/spring-with-maven

You will also be interested:

Id rather get down to work. Igor suddenly went in their direction. The girls' hearts first stopped, then jumped to unimaginable heights. He hung over their table with his hands on the edges. - What are we arguing about, girls.



3301 3302 3303 3304 3305