码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot2.0.2 不使用parent作为maven单继承方式操作 : org.springframework.boot : spring-boot-dependencies : 2.0.2.RELEASE

时间:2018-05-20 10:41:45      阅读:843      评论:0      收藏:0      [点我收藏+]

标签:oid   ann   string   分享图片   des   target   1.0   .config   pom   

1、pom配置方式
技术分享图片
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 4     <modelVersion>4.0.0</modelVersion>
 5 
 6     <groupId>com.springboot</groupId>
 7     <artifactId>quick_start</artifactId>
 8     <version>0.0.1-SNAPSHOT</version>
 9     <packaging>jar</packaging>
10 
11     <name>quick_start</name>
12     <url>http://maven.apache.org</url>
13     <description>Demo project for Spring Boot</description>
14 
15     <properties>
16         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
18         <maven.compiler.source>1.8</maven.compiler.source>
19         <maven.compiler.target>1.8</maven.compiler.target>
20         <java.version>1.8</java.version>
21     </properties>
22 
23     <dependencies>
24         <!--不使用parent方式进行依赖,需要scope和type设置-->
25         <dependency>
26             <groupId>org.springframework.boot</groupId>
27             <artifactId>spring-boot-dependencies</artifactId>
28             <version>2.0.2.RELEASE</version>
29             <scope>import</scope>
30             <type>pom</type>
31         </dependency>
32 
33 
34         <dependency>
35             <groupId>org.springframework.boot</groupId>
36             <artifactId>spring-boot-starter-web</artifactId>
37         </dependency>
38 
39         <dependency>
40             <groupId>org.springframework.boot</groupId>
41             <artifactId>spring-boot-starter-test</artifactId>
42             <scope>test</scope>
43         </dependency>
44     </dependencies>
45 
46     <build>
47         <plugins>
48             <plugin>
49                 <groupId>org.springframework.boot</groupId>
50                 <artifactId>spring-boot-maven-plugin</artifactId>
51             </plugin>
52         </plugins>
53     </build>
54 
55 
56 </project>
View Code

2、实体类编写

技术分享图片
 1 package com.springboot;
 2 
 3 import org.springframework.boot.SpringApplication;
 4 import org.springframework.boot.autoconfigure.SpringBootApplication;
 5 import org.springframework.context.ConfigurableApplicationContext;
 6 import org.springframework.context.annotation.Bean;
 7 
 8 /******************************
 9  * @Author : liuyang
10  * @ClassName : QuickStartApplication
11  * @Date : 2018 五月  20
12  * @Time : 01:05:59
13  * @Type : SpringBoot
14  * @Version : 1.0
15  * @Return :
16  * @Description :
17  *******************************/
18 
19 @SpringBootApplication
20 public class QuickStartApplication {
21 
22     @Bean
23     public Runnable createRunnable() {
24 
25         return () -> {
26             System.out.println("Spring Boot is Run");
27         };
28 
29     }
30 
31     public static void main(String[] args) {
32         ConfigurableApplicationContext applicationContext = SpringApplication.run(QuickStartApplication.class,args);
33         applicationContext.getBean(Runnable.class).run();
34     }
35 }
View Code

源码存放:
      需要将parent部分注释掉
        https://github.com/liushaoye/quick_start

SpringBoot2.0.2 不使用parent作为maven单继承方式操作 : org.springframework.boot : spring-boot-dependencies : 2.0.2.RELEASE

标签:oid   ann   string   分享图片   des   target   1.0   .config   pom   

原文地址:https://www.cnblogs.com/liuyangfirst/p/9062309.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!