不使用 spring-boot-starter-parent 构建 spring boot 应用
创建 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>
需求描述:SpringBoot快速入门, 这篇博客记录如何使用SpringBoot快速创建一个HelloWorld程序。其中,在pom文件中,使用的SpringBoot提供的父依赖项目。在真实的企业级项目,我们可能会有自己的父项目,不想依赖Spring提供的父项目。那么如何解决呢?
- 第一步:修改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快速入门程序一样,启动类和测试步骤均一样。
不使用 spring-boot-starter-parent 构建 spring boot 应用的更多相关文章
- [转]Spring Boot——2分钟构建spring web mvc REST风格HelloWorld
Spring Boot——2分钟构建spring web mvc REST风格HelloWorld http://projects.spring.io/spring-boot/ http://spri ...
- Springboot(一):使用Intellij中的Spring Initializr来快速构建Spring Boot工程
使用Intellij中的Spring Initializr来快速构建Spring Boot工程 New---Project 可以看到图所示的创建功能窗口.其中Initial Service Url指向 ...
- Spring Boot——2分钟构建spring web mvc REST风格HelloWorld
之前有一篇<5分钟构建spring web mvc REST风格HelloWorld>介绍了普通方式开发spring web mvc web service.接下来看看使用spring b ...
- 使用Intellij中的Spring Initializr来快速构建Spring Boot/Cloud工程(十五)
在之前的所有Spring Boot和Spring Cloud相关博文中,都会涉及Spring Boot工程的创建.而创建的方式多种多样,我们可以通过Maven来手工构建或是通过脚手架等方式快速搭建,也 ...
- 使用Intellij中的Spring Initializr来快速构建Spring Boot/Cloud工程
在之前的所有Spring Boot和Spring Cloud相关博文中,都会涉及Spring Boot工程的创建.而创建的方式多种多样,我们可以通过Maven来手工构建或是通过脚手架等方式快速搭建,也 ...
- Spring Boot教程(十五)使用Intellij中的Spring Initializr来快速构建Spring Boot/Cloud工程
在之前的所有Spring Boot和Spring Cloud相关博文中,都会涉及Spring Boot工程的创建.而创建的方式多种多样,我们可以通过Maven来手工构建或是通过脚手架等方式快速搭建,也 ...
- 使用Intellij中的Spring Initializr来快速构建Spring Boot工程
本文将介绍嵌入的Intellij中的Spring Initializr工具,它同Web提供的创建功能一样,可以帮助我们快速的构建出一个基础的Spring Boot/Cloud工程. 1.菜单栏中选择F ...
- spring boot 入门一 构建spring boot 工程
最近在学习Spring boot,所以想通过博客的形式和大家分享学习的过程,同时也为了更好的学习技术,下面直接进入Spring boot的世界. 简介 spring boot 它的设计目的就是为例简化 ...
- SpringCloud核心教程 | 第一篇: 使用Intellij中的Spring Initializr来快速构建Spring Cloud工程
spring cloud简介 spring cloud 为开发人员提供了快速构建分布式系统的一些工具,包括配置管理.服务发现.断路器.路由.微代理.事件总线.全局锁.决策竞选.分布式会话等等.它运行环 ...
- Spring Boot (一): Spring Boot starter自定义
前些日子在公司接触了spring boot和spring cloud,有感于其大大简化了spring的配置过程,十分方便使用者快速构建项目,而且拥有丰富的starter供开发者使用.但是由于其自动化配 ...
随机推荐
- 2016.6.20 在Eclipse配置Tomcat服务器的步骤
好久没接触,又忘记了如何在eclipse中配置tomcat. (1)打开eclispe的preference (2)找到Server下方的Runtime Environment,单击右方的Add按钮. ...
- 14. Spring Boot定时任务的使用【从零开始学Spring Boot】
com.kfit.base.scheduling.SchedulingConfig: package com.kfit.base.scheduling; import org.springframew ...
- vuex 中关于 mapGetters 的作用
mapGetters 工具函数会将 store 中的 getter 映射到局部计算属性中.它的功能和 mapState 非常类似,我们来直接看它的实现: export function mapGett ...
- 【Python】从文件中读取数据
从文件中读取数据 1.1 读取整个文件 要读取文件,需要一个包含几行文本的文件(文件PI_DESC.txt与file_reader.py在同一目录下) PI_DESC.txt 3.1415926535 ...
- SQL Server常用系统表
1.查询当前数据库中的用户表 select *from sysobjects where xtype='U'; 2.获取SQL Server允许同时用户连接的最大数 SELECT @@MAX_CONN ...
- 怎样替换jar包的指定文件
在做(或修改别人的)项目的时候,可能遇到要修改调用的的jar包内的类属性或方法的问题.在eclipse或是其他的IDE中是无法直接修改的,所以需要一个解压jar-->修改文件-->编译-- ...
- java操作pdf
使用pdf模板生成pdf 1,工具 Adobe Acrobat X Pro 2,pom文件配置 <dependency> <groupId>com.itextpdf</g ...
- 最简单的PHP开发环境搭建
近期发现一个非常easy的,适合刚開始学习的人的PHP开发环境,整个环境仅仅有三样东东,PHP ,APACHE , MYSQL可是对于初学PHP的人来说,己经足够了. 假设有兴趣的话能够直接去百度PN ...
- js 检测客户端网速
<!doctype html> <html> <head> <meta http-equiv=Content-Type content="text/ ...
- C++复习:位运算
与 a&b : 1010&1100=1000 或 a|b : 1010|1100=1110 异或 a^b : 101 ...