官术网_书友最值得收藏!

Setting up the development environment

Spring projects are usually created as Java projects based in Maven, Gradle, or Ivy (which are build automation and dependency management tools). You can easily create a Maven-based Spring project using STS or Eclipse with Spring Tools support. You need to make sure your pom.xml (Maven configuration) file contains, at the minimum, a dependency to spring-context:

<dependencies>
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>${spring-framework.version}</version>
  </dependency>
  ...
</dependencies>

Of course, you should add further dependencies to modules such as spring-tx, spring-data-jpa, spring-webmvc, and hibernate, depending on your project type and requirements.

Unless you explicitly specify the repository location, your project works with Maven's central repository. Alternatively, you can point to Spring's official Maven repository (for example, for milestones and snapshots) by specifying it in your pom.xml file:

<repositories>
    <repository>
        <id>io.spring.repo.maven.milestone</id>
        <url>http://repo.spring.io/milestone/</url>
        <snapshots><enabled>false</enabled></snapshots>
    </repository>
</repositories>

You can use the Spring release, milestone, and snapshot repositories as required.

If you are using Gradle as your build system, you can declare your dependencies (typically in the build.gradle file) as follows:

dependencies {
    compile('org.springframework:spring-context')
    compile('org.springframework:spring-tx')
    compile('org.hibernate:hibernate-entitymanager')
    testCompile('junit:junit')
}

If you prefer using the Ivy dependency management tool, then your Spring dependency configuration will look like this:

<dependency org="org.springframework"
    name="spring-core" rev="4.2.0.RC3" conf="compile->runtime"/>
主站蜘蛛池模板: 阿坝县| 禹城市| 聂荣县| 新疆| 博兴县| 苏尼特左旗| 浪卡子县| 仁寿县| 马山县| 东乡县| 葫芦岛市| 潞城市| 吴川市| 稷山县| 普宁市| 嘉定区| 保山市| 桐柏县| 万年县| 屯昌县| 敦煌市| 商水县| 赤峰市| 班戈县| 日照市| 申扎县| 江门市| 宣化县| 沁阳市| 通河县| 石阡县| 白河县| 巧家县| 哈尔滨市| 汉寿县| 察雅县| 融水| 桓台县| 淮北市| 深州市| 油尖旺区|