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

  • Spring Essentials
  • Shameer Kunjumohamed Hamidreza Sattari
  • 186字
  • 2021-07-16 13:05:46

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"/>
主站蜘蛛池模板: 威海市| 甘孜| 天峻县| 金湖县| 二连浩特市| 资中县| 柳州市| 木兰县| 玉屏| 娄底市| 靖江市| 泰州市| 宜兰市| 贵溪市| 通州区| 莎车县| 宕昌县| 驻马店市| 安新县| 雅江县| 富阳市| 名山县| 象山县| 应城市| 九寨沟县| 汽车| 鸡泽县| 甘孜县| 启东市| 安义县| 弥渡县| 乡城县| 锦屏县| 中山市| 丽江市| 合江县| 英山县| 武穴市| 鄂尔多斯市| 奉新县| 南丰县|