创建 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. jmeter3.x的jtx文件解析

    jtl保存测试结果 打开jtl文件,内容为下: timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,suc ...

  2. winsock 收发广播包 【转】

    winsock 收发广播包 ☛广播包的概念 广播包通常为了如下两个原因使用:1 一个应用程序希望在本地网络中找到一个资源,而应用程序对于该资源的地址又没有任何先验的知识. 2 一些重要的功能,例如路由 ...

  3. Oracle数据泵远程导入文件到本地数据库

    --以dba身份登录 C:\Users\Administrator>sqlplus / as sysdba --创建用户 SQL> create user bfzg0828 identif ...

  4. linux中grep注意

    grep -l 只输出文件名: -h 只输出匹配的行 不输出文件名: -c 之处匹配内容的行数: -n 将结果输出的同时,也输出改行的行号: -c 统计查到的总行数: -i 忽略大小写: grep ' ...

  5. Linux装mysqli.so

    php 5.2.3+mysqli 安装与常见错误 总结 php 5.2.3+mysqli 安装与常见错误 总结   记得原来在编译php的已经已经加上参数--with-mysql=/usr/local ...

  6. Git-flow 基本使用方法

    本文参考自:https://juejin.im/entry/5ad9a28d6fb9a07ac76e5e22 1.分支模型 master 分支:用于上线的分支,保护性分支,只包含经过测试的稳定代码,开 ...

  7. 【Python】学习笔记十五:循环对象

    循环对象 所谓的循环对象,包含有一个next()方法(python3中为__next__() ),这个方法的目的就是进行到下一个结果,而在结束一系列结果之后,举出StopIteration错误 当一个 ...

  8. 常用组件介绍 ---- Layout_weight

      下面这些也可以算是组件 文本区 TextView 文本框 EditText layout  容器 view     千万不要把Layout_weight 与 Layout_width相混淆**** ...

  9. 用Putty连接Linux

    随着linux应用的普及,linux管理越来越依赖远程管理.在各种telnet类工具中,putty是其中最出色的一个. 一.Putty简介     Putty是一个免费小巧的Win32平台下的teln ...

  10. hdu 1203 I NEED A OFFER!(01背包)

    题意:"至少一份offer的最大概率".即求拿不到offer的最小概率 (得到offer的最大概率 = 1 - 反例的最小概率). 状态转移方程:dp[j]= Min(dp[j], ...