這篇文章主要介紹Springboot如何創(chuàng)建子父工程,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)公司專(zhuān)注為客戶(hù)提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于做網(wǎng)站、成都網(wǎng)站建設(shè)、故城網(wǎng)絡(luò)推廣、重慶小程序開(kāi)發(fā)公司、故城網(wǎng)絡(luò)營(yíng)銷(xiāo)、故城企業(yè)策劃、故城品牌公關(guān)、搜索引擎seo、人物專(zhuān)訪(fǎng)、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供故城建站搭建服務(wù),24小時(shí)服務(wù)熱線(xiàn):13518219792,官方網(wǎng)址:www.cdcxhl.com
1.創(chuàng)建子父工程
2.添加pom配置文件
2.1 父工程pom.xml
4.0.0 com.demo springboot 0.0.1-SNAPSHOT pom springboot-server springboot-common springboot-domain springboot-sdk UTF-8 1.8 1.5.9.RELEASE 4.3.13.RELEASE 1.7.25 1.2.8 3.1 2.5 1.9.3 1.11 19.0 org.springframework.boot spring-boot-starter-tomcat ${spring.boot.version} org.springframework.boot spring-boot-starter-actuator ${spring.boot.version} org.springframework.boot spring-boot-starter-web ${spring.boot.version} org.springframework spring-context ${spring.version} org.springframework spring-core ${spring.version} com.alibaba fastjson ${fastjson.version} org.apache.commons commons-lang3 ${commons.lang.version} commons-io commons-io ${commons.io.version} commons-beanutils commons-beanutils ${commons.beanutils.version} commons-codec commons-codec ${commons.codec.version} com.google.guava guava ${guava.version} org.springframework.boot spring-boot-starter-test ${spring.boot.version} test org.slf4j slf4j-api ${slf4j.version} nexus-releases Nexus Release Repository http://ip:9090/repository/releases/ nexus-snapshots Nexus Snapshot Repository http://ip:9090/repository/snapshots/ org.apache.maven.plugins maven-compiler-plugin 3.1 ${build.jdk.version} org.sonarsource.scanner.maven sonar-maven-plugin 3.2
2.2 子工程springboot-server pom.xml:
4.0.0 com.demo springboot 0.0.1-SNAPSHOT springboot-server springboot-server com.demo.Application org.springframework.boot spring-boot-starter-tomcat org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-starter-web com.alibaba fastjson org.apache.commons commons-lang3 commons-io commons-io commons-beanutils commons-beanutils commons-codec commons-codec com.google.guava guava net.sf.ehcache ehcache 2.10.5 src/main/java src/main/resources true *.properties *.yml *.xml src/main/resources false scripts/* *.properties *.yml *.xml src/main/resources/scripts ${project.build.directory}/bin true *.sh *.bat src/main/resources ${project.build.directory}/conf true *.properties *.yml *.xml lib ${project.build.directory}/lib org.apache.maven.plugins maven-jar-plugin 2.6 ${project.build.directory}/lib true lib/ *.xml *.yml *.properties org.apache.maven.plugins maven-dependency-plugin copy-dependencies package copy-dependencies ${project.build.directory}/lib maven-source-plugin 2.4 true ${project.build.directory} compile jar org.apache.maven.plugins maven-assembly-plugin dfrp-portal ${application.main.class} src/main/resources/scripts/assembly.xml ${project.name}-${version} package single
3.App啟動(dòng)類(lèi)
/** * Copyright (c) 2020, All Rights Reserved. * */ package com.demo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.Banner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { private static final Logger LOG = LoggerFactory.getLogger(Application.class); public static void main(String[] args) { SpringApplication app = new SpringApplication(Application.class); app.setBannerMode(Banner.Mode.OFF); app.setWebEnvironment(true); app.run(args); LOG.info("**************** Startup Success ****************"); } }
4.application.yml配置文件
version: ${project.version} server: port: 7070 session-timeout: 0 context-path: /
5.測(cè)試controller類(lèi)
package com.demo.server.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class TestController { @RequestMapping("/helloworld") public String hello(String name) { return "name"+name; } }
springboot子父項(xiàng)目啟動(dòng)成功。
以上是“Springboot如何創(chuàng)建子父工程”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!