欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解用maven搭建springboot環(huán)境的方法

 更新時(shí)間:2017年08月31日 10:06:27   作者:somefuture  
本篇文章主要介紹了詳解用maven搭建springboot環(huán)境的方法,這里整理了詳細(xì)的代碼,非常具有實(shí)用價(jià)值,有需要的小伙伴可以參考下

SpringBoot不是一個(gè)新框架,它是讓開發(fā)者更快的開發(fā)Spring應(yīng)用的一條捷徑。使用它和使用標(biāo)準(zhǔn)java類庫(kù)一樣,只要簡(jiǎn)單的指定合適的 spring-boot-*.jar 就可以了。這里我們說(shuō)怎么用maven導(dǎo)入SpringBoot的包。

 SpringBoot要去Maven的版本達(dá)到3.2或以上,Maven的下載地址是 maven.apache.org.

SpringBoot的依賴包形式都如 org.springframework.boot + groupId,一般是繼承項(xiàng)目 spring-boot-starter-parent。下面是一個(gè)典型的POM文件:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
  <modelVersion>4.0.0</modelVersion> 
 
  <groupId>com.example</groupId> 
  <artifactId>myproject</artifactId> 
  <version>0.0.1-SNAPSHOT</version> 
 
  <!-- Inherit defaults from Spring Boot --> 
  <parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.3.0.BUILD-SNAPSHOT</version> 
  </parent> 
 
  <!-- Add typical dependencies for a web application --> 
  <dependencies> 
    <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
  </dependencies> 
 
  <!-- Package as an executable jar --> 
  <build> 
    <plugins> 
      <plugin> 
        <groupId>org.springframework.boot</groupId> 
        <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
    </plugins> 
  </build> 
 
  <!-- 使用 Spring repositories --> 
  <!-- (我們使用的是SNAPSHOT版本,如果用RELEASE版本下面的偶不用寫) --> 
  <repositories> 
    <repository> 
      <id>spring-snapshots</id> 
      <url>http://repo.spring.io/snapshot</url> 
      <snapshots><enabled>true</enabled></snapshots> 
    </repository> 
    <repository> 
      <id>spring-milestones</id> 
      <url>http://repo.spring.io/milestone</url> 
    </repository> 
  </repositories> 
  <pluginRepositories> 
    <pluginRepository> 
      <id>spring-snapshots</id> 
      <url>http://repo.spring.io/snapshot</url> 
    </pluginRepository> 
    <pluginRepository> 
      <id>spring-milestones</id> 
      <url>http://repo.spring.io/milestone</url> 
    </pluginRepository> 
  </pluginRepositories> 
</project> 

Parent里面把版本指定好了,下面的依賴項(xiàng)就不能指定版本了。如果你不想要它固定的版本,可以自己修改。怎么改呢?很簡(jiǎn)單,只要指定scope為import就行:

<dependencyManagement> 
   <dependencies> 
    <dependency> 
      <!-- Import dependency management from Spring Boot --> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-dependencies</artifactId> 
      <version>1.3.0.BUILD-SNAPSHOT</version> 
      <type>pom</type> 
      <scope>import</scope> 
    </dependency> 
  </dependencies> 
</dependencyManagement> 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論