最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot與docker的結(jié)合的示例

 更新時(shí)間:2018年03月26日 09:32:02   作者:數(shù)齊  
本篇文章主要介紹了SpringBoot與docker的結(jié)合的示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

最近一段時(shí)間,容器化成為了一種趨勢(shì)。一臺(tái)服務(wù)器可以虛擬成多個(gè)容器,同時(shí)提供服務(wù),共享硬件資源,節(jié)約成本,容器化的翹楚就是Docker,我司的所有微服務(wù)的發(fā)布都已經(jīng)容器化。spring boot 也緊跟潮流,加入了Docker的maven插件,可以通過(guò)執(zhí)行命令來(lái)制作鏡像。

本節(jié)的主要內(nèi)容不是講代碼,而是講這個(gè)Docker插件。廢話不多說(shuō),上pom

<plugin>
        <groupId>com.spotify</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>0.4.12</version>
        <configuration>
          <!-- 注意imageName一定要是符合正則[a-z0-9-_.]的,否則構(gòu)建不會(huì)成功 -->
          <!-- 詳見(jiàn):https://github.com/spotify/docker-maven-plugin  Invalid repository name ... only [a-z0-9-_.] are allowed-->
          <imageName>spring-boot-docker-start</imageName>
          <!--相當(dāng)于from java,本地有使用本地的鏡像,沒(méi)有的話從遠(yuǎn)程倉(cāng)庫(kù)拉取-->
          <baseImage>java</baseImage>
          <exposes>
            <!--暴露容器內(nèi)的8080端口-->
            <expose>8080</expose>
          </exposes>
          <!--進(jìn)入點(diǎn),執(zhí)行的命令-->
          <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
          <resources>
            <resource>
              <targetPath>/</targetPath>
              <directory>${project.build.directory}</directory>
              <include>${project.build.finalName}.jar</include>
            </resource>
          </resources>
        </configuration>
      </plugin>

imageName就是鏡像的名稱。baseImage是基礎(chǔ)鏡像,本地有使用本地的鏡像,沒(méi)有的話從遠(yuǎn)程倉(cāng)庫(kù)拉取,暴露容器內(nèi)的8080端口,執(zhí)行java -jar 命令,啟動(dòng)微服務(wù)。我們知道使用Docker需要制定Dockerfile文件,里面的元素完全通過(guò)maven插件的標(biāo)簽來(lái)體現(xiàn)了。還是有前提的,你得先安裝好Docker。講解到這里,我們開(kāi)始運(yùn)行

第一步:執(zhí)行mvn clean package docker:build創(chuàng)建生成鏡像。

第二步:?jiǎn)?dòng)鏡像docker run -it -P spring-boot-docker-start,看下容器內(nèi)的日志

➜ spring-boot-docker-start git:(master) docker run -it -P spring-boot-docker-start

 .  ____     _      __ _ _
 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/ ___)| |_)| | | | | || (_| | ) ) ) )
 ' |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::    (v1.3.5.RELEASE)

2018-03-25 08:41:56.274 INFO 1 --- [      main] com.shuqi.ApplicationMain        : Starting ApplicationMain on 075543f8f5b6 with PID 1 (/spring-boot-docker-start.jar started by root in /)
2018-03-25 08:41:56.287 INFO 1 --- [      main] com.shuqi.ApplicationMain        : No active profile set, falling back to default profiles: default
2018-03-25 08:41:56.406 INFO 1 --- [      main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@126d28d3: startup date [Sun Mar 25 08:41:56 UTC 2018]; root of context hierarchy
2018-03-25 08:41:58.356 INFO 1 --- [      main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-03-25 08:41:58.382 INFO 1 --- [      main] o.apache.catalina.core.StandardService  : Starting service Tomcat
2018-03-25 08:41:58.384 INFO 1 --- [      main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.33
2018-03-25 08:41:58.512 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]    : Initializing Spring embedded WebApplicationContext
2018-03-25 08:41:58.512 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader      : Root WebApplicationContext: initialization completed in 2113 ms
2018-03-25 08:41:58.920 INFO 1 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean    : Mapping servlet: 'dispatcherServlet' to [/]
2018-03-25 08:41:58.928 INFO 1 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-03-25 08:41:58.937 INFO 1 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-03-25 08:41:58.937 INFO 1 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-03-25 08:41:58.938 INFO 1 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-03-25 08:41:59.406 INFO 1 --- [      main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@126d28d3: startup date [Sun Mar 25 08:41:56 UTC 2018]; root of context hierarchy
2018-03-25 08:41:59.516 INFO 1 --- [      main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello],methods=[GET]}" onto public java.lang.String com.shuqi.controller.HelloController.hello()
2018-03-25 08:41:59.523 INFO 1 --- [      main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-03-25 08:41:59.524 INFO 1 --- [      main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-03-25 08:41:59.584 INFO 1 --- [      main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-25 08:41:59.585 INFO 1 --- [      main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-25 08:41:59.645 INFO 1 --- [      main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-03-25 08:41:59.754 INFO 1 --- [      main] o.s.j.e.a.AnnotationMBeanExporter    : Registering beans for JMX exposure on startup
2018-03-25 08:41:59.834 INFO 1 --- [      main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-03-25 08:41:59.838 INFO 1 --- [      main] com.shuqi.ApplicationMain        : Started ApplicationMain in 4.084 seconds (JVM running for 5.012)
[2018-03-25 08:41:59] server started!

啟動(dòng)成功。

第三步:輸入docker ps看看容器內(nèi)的8080端口被映射到了本機(jī)的哪個(gè)端口

CONTAINER ID    IMAGE           COMMAND         CREATED       STATUS       PORTS           NAMES
075543f8f5b6    spring-boot-docker-start  "java -jar /spring..."  About a minute ago  Up About a minute  0.0.0.0:32768->8080/tcp  trusting_noether

確定是32768端口。

第四步:瀏覽器中輸入http://localhost:32768/hello,看到結(jié)果

說(shuō)明我們?cè)L問(wèn)容器內(nèi)的程序成功了!

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 由淺入深快速掌握J(rèn)ava?數(shù)組的使用

    由淺入深快速掌握J(rèn)ava?數(shù)組的使用

    Java?數(shù)組?數(shù)組對(duì)于每一門編程語(yǔ)言來(lái)說(shuō)都是重要的數(shù)據(jù)結(jié)構(gòu)之一,當(dāng)然不同語(yǔ)言對(duì)數(shù)組的實(shí)現(xiàn)及處理也不盡相同。?Java?語(yǔ)言中提供的數(shù)組是用來(lái)存儲(chǔ)固定大小的同類型元素
    2022-04-04
  • java實(shí)現(xiàn)猜拳游戲

    java實(shí)現(xiàn)猜拳游戲

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)猜拳游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-08-08
  • java并發(fā)之ArrayBlockingQueue詳細(xì)介紹

    java并發(fā)之ArrayBlockingQueue詳細(xì)介紹

    這篇文章主要介紹了java并發(fā)之ArrayBlockingQueue詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • 安裝elasticsearch-analysis-ik中文分詞器的步驟講解

    安裝elasticsearch-analysis-ik中文分詞器的步驟講解

    今天小編就為大家分享一篇關(guān)于安裝elasticsearch-analysis-ik中文分詞器的步驟講解,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-02-02
  • mybatis where 標(biāo)簽使用

    mybatis where 標(biāo)簽使用

    where標(biāo)記的作用類似于動(dòng)態(tài)sql中的set標(biāo)記,本文主要介紹了mybatis where 標(biāo)簽使用,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • spring profile 多環(huán)境配置管理詳解

    spring profile 多環(huán)境配置管理詳解

    這篇文章主要介紹了 spring profile 多環(huán)境配置管理詳解的相關(guān)資料,需要的朋友可以參考下
    2017-01-01
  • Java集合Stream流操作的基本使用教程分享

    Java集合Stream流操作的基本使用教程分享

    流操作并不會(huì)影響原來(lái)的集合,可以簡(jiǎn)單認(rèn)為,流操作是把集合中的一個(gè)元素逐個(gè)復(fù)制放到一個(gè)首尾相接的流動(dòng)的水槽中。這篇文章整理了Stream流操作的基本使用,需要的可以參考一下
    2023-02-02
  • Mybatis?MappedStatement類核心原理詳解

    Mybatis?MappedStatement類核心原理詳解

    這篇文章主要介紹了Mybatis?MappedStatement類,mybatis的mapper文件最終會(huì)被解析器,解析成MappedStatement,其中insert|update|delete|select每一個(gè)標(biāo)簽分別對(duì)應(yīng)一個(gè)MappedStatement
    2022-11-11
  • Java中Date和Calendar常用方法

    Java中Date和Calendar常用方法

    這篇文章主要為大家詳細(xì)介紹了Java中Date和Calendar常用用法,感興趣的小伙伴們可以參考一下
    2016-09-09
  • java控制臺(tái)輸出版多人聊天室

    java控制臺(tái)輸出版多人聊天室

    這篇文章主要為大家詳細(xì)介紹了java控制臺(tái)輸出版多人聊天室,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-09-09

最新評(píng)論

望奎县| 东丰县| 交城县| 东兴市| 达拉特旗| 雷波县| 安龙县| 射阳县| 赣榆县| 镇赉县| 唐山市| 探索| 桃园市| 灵寿县| 子长县| 大英县| 肥城市| 手机| 临湘市| 图们市| 正定县| 南宫市| 巴东县| 平定县| 宣武区| 丰城市| 若尔盖县| 宁波市| 丰宁| 民和| 旺苍县| 寻甸| 新宁县| 汉中市| 盱眙县| 内黄县| 绿春县| 南郑县| 图片| 呼玛县| 朝阳市|