创建 spring-boot 应用通用方法是配置 pom.xml,定义 为 spring-boot-start-parent。如下:

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

但是在真正的项目开发中,往往模块需要定义自己的 而 maven 的 pom 只允许一个 存在,这种情况下,可以采用下面的定义来避免使用 spring-boot-start-parent。安装如下配置的 pom.xml 可以通过 maven package 生成可以运行的 jar 包,通过 java -jar xxxx.jar 启动运行。

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.4.0.RELEASE</version>
</dependency> <!--ImportdependencymanagementfromSpringBoot-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.0.RELEASE</version>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </build>
版权声明:本文为崔瑜原创文章,未经博主允许不得转载。 http://blog.csdn.net/cuiy6642/article/details/52131399
 
 

需求描述:SpringBoot快速入门, 这篇博客记录如何使用SpringBoot快速创建一个HelloWorld程序。其中,在pom文件中,使用的SpringBoot提供的父依赖项目。在真实的企业级项目,我们可能会有自己的父项目,不想依赖Spring提供的父项目。那么如何解决呢?

  1. 第一步:修改pom文件,将原来的parent节点替换成如下依赖即可:
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.4.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency> </dependencies>
</dependencyManagement>

其余配置和SpringBoot快速入门程序一样,启动类和测试步骤均一样。

参考链接:http://docs.spring.io/spring-boot/docs/1.4.3.RELEASE/reference/htmlsingle/#using-boot-maven-without-a-parent

源代码链接:https://github.com/myNameIssls/springboot-study

版权声明:本文为博主原创文章,未经博主允许不得转载。 http://blog.csdn.net/myNameIssls/article/details/54613426

不使用 spring-boot-starter-parent 构建 spring boot 应用的更多相关文章

  1. [转]Spring Boot——2分钟构建spring web mvc REST风格HelloWorld

    Spring Boot——2分钟构建spring web mvc REST风格HelloWorld http://projects.spring.io/spring-boot/ http://spri ...

  2. Springboot(一):使用Intellij中的Spring Initializr来快速构建Spring Boot工程

    使用Intellij中的Spring Initializr来快速构建Spring Boot工程 New---Project 可以看到图所示的创建功能窗口.其中Initial Service Url指向 ...

  3. Spring Boot——2分钟构建spring web mvc REST风格HelloWorld

    之前有一篇<5分钟构建spring web mvc REST风格HelloWorld>介绍了普通方式开发spring web mvc web service.接下来看看使用spring b ...

  4. 使用Intellij中的Spring Initializr来快速构建Spring Boot/Cloud工程(十五)

    在之前的所有Spring Boot和Spring Cloud相关博文中,都会涉及Spring Boot工程的创建.而创建的方式多种多样,我们可以通过Maven来手工构建或是通过脚手架等方式快速搭建,也 ...

  5. 使用Intellij中的Spring Initializr来快速构建Spring Boot/Cloud工程

    在之前的所有Spring Boot和Spring Cloud相关博文中,都会涉及Spring Boot工程的创建.而创建的方式多种多样,我们可以通过Maven来手工构建或是通过脚手架等方式快速搭建,也 ...

  6. Spring Boot教程(十五)使用Intellij中的Spring Initializr来快速构建Spring Boot/Cloud工程

    在之前的所有Spring Boot和Spring Cloud相关博文中,都会涉及Spring Boot工程的创建.而创建的方式多种多样,我们可以通过Maven来手工构建或是通过脚手架等方式快速搭建,也 ...

  7. 使用Intellij中的Spring Initializr来快速构建Spring Boot工程

    本文将介绍嵌入的Intellij中的Spring Initializr工具,它同Web提供的创建功能一样,可以帮助我们快速的构建出一个基础的Spring Boot/Cloud工程. 1.菜单栏中选择F ...

  8. spring boot 入门一 构建spring boot 工程

    最近在学习Spring boot,所以想通过博客的形式和大家分享学习的过程,同时也为了更好的学习技术,下面直接进入Spring boot的世界. 简介 spring boot 它的设计目的就是为例简化 ...

  9. SpringCloud核心教程 | 第一篇: 使用Intellij中的Spring Initializr来快速构建Spring Cloud工程

    spring cloud简介 spring cloud 为开发人员提供了快速构建分布式系统的一些工具,包括配置管理.服务发现.断路器.路由.微代理.事件总线.全局锁.决策竞选.分布式会话等等.它运行环 ...

  10. Spring Boot (一): Spring Boot starter自定义

    前些日子在公司接触了spring boot和spring cloud,有感于其大大简化了spring的配置过程,十分方便使用者快速构建项目,而且拥有丰富的starter供开发者使用.但是由于其自动化配 ...

随机推荐

  1. python模块相关

    aniso8601 pyquery networkx (2.0)                 - Python package for creating and manipulating grap ...

  2. openssl之EVP系列之12---EVP_Seal系列函数介绍

    openssl之EVP系列之12---EVP_Seal系列函数介绍     ---依据openssl doc/crypto/EVP_SealInit.pod翻译和自己的理解写成     (作者:Dra ...

  3. HTML5 Canvas 绘制五角星

    代码: <!DOCTYPE html> <html lang="utf-8"> <meta http-equiv="Content-Type ...

  4. AutoCAD如何快速标注零件序号

    1 先画好一条直线和一个数字   2 选中刚才绘制的数字和直线,选择阵列(估计大概要画四十个就阵列四十行,改一下行偏移)   预览效果如图所示   随后不断重复直线即可   横向也是一样   最后双击 ...

  5. 03_Nginx加入新模块

     1 进入nginx安装文件夹,查看nginx版本号及其编译參数: [root@localhost nginx]# ./nginx -V nginx version: nginx/1.8.0 bu ...

  6. 【剑指Offer学习】【面试题37:两个链表的第一个公共结点】

    题目:输入两个链表,找出它们的第一个公共结点. 链表结点定义 /** * 链表结点类 */ private static class ListNode { int val; ListNode next ...

  7. 利用动态图添加Loading动画

    opacity:CSS3中的属性,调节透明度,一般取值0.5 添加思想: 1.对超链接添加点击事件,通过new {@onclick="showLoading()"} Html.Ac ...

  8. 在MyEclipse上部署Tomcatserver

    我在前面的博客中介绍了在Windows下安装Tomcatserver.这篇博客将介绍在MyEclipse上部署Tomcatserver 第一步:启动MyEclipse 第二步:选项Window-> ...

  9. ie 浏览器无法保存cookie,且与域名包括了下划线(_)有关系的问题

    <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255) ...

  10. hdu1081 最大子矩阵

    最大子矩阵自然直在最大连续子序列的升级版  只是其原理都是用到了动态规划思想     仅仅是矩阵用到了枚举 +合并       把非常多列看成是一列的和 #include<stdio.h> ...