亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Docker遇到Intellij IDEA,Java開(kāi)發(fā)提升了十倍生產(chǎn)力

 更新時(shí)間:2020年10月20日 09:54:43   作者:動(dòng)力節(jié)點(diǎn)官方博客  
這篇文章主要介紹了Docker遇到Intellij IDEA,Java開(kāi)發(fā)提升了十倍生產(chǎn)力,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

Idea是Java開(kāi)發(fā)利器,SpringBoot是Java生態(tài)中最流行的微服務(wù)框架,docker是時(shí)下最火的容器技術(shù),那么它們結(jié)合在一起會(huì)產(chǎn)生什么化學(xué)反應(yīng)呢?

一、開(kāi)發(fā)前準(zhǔn)備

1. Docker的安裝可以參考https://docs.docker.com/install/

2. 配置docker遠(yuǎn)程連接端口

 vi /usr/lib/systemd/system/docker.service

找到 ExecStart,在最后面添加 -H tcp://0.0.0.0:2375,如下圖所示

3. 重啟docker

systemctl daemon-reload
 systemctl restart docker

4.開(kāi)放端口

firewall-cmd --zone=public --add-port=2375/tcp --permanent

5.Idea安裝docker插件,重啟

6.連接遠(yuǎn)程docker

(1) 編輯配置

(2) 填遠(yuǎn)程docker地址

(3) 連接成功,會(huì)列出遠(yuǎn)程docker容器和鏡像

 二、新建項(xiàng)目

創(chuàng)建springboot項(xiàng)目

項(xiàng)目結(jié)構(gòu)圖

(1) 配置pom文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.fengqi</groupId>
    <artifactId>dockerDemo</artifactId>
    <version>1.0.0</version>
    <relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
  </parent>
  <groupId>com.fengqi</groupId>
  <artifactId>web</artifactId>
  <version>1.0.0</version>
  <name>web</name>
  <description>Demo project for Spring Boot</description>
  
 <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
    </dependency>
 
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </dependency>
  </dependencies>
 
  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.spotify</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>1.0.0</version>
        <configuration>
          <dockerDirectory>src/main/docker</dockerDirectory>
          <resources>
            <resource>
              <targetPath>/</targetPath>
              <directory>${project.build.directory}</directory>
              <include>${project.build.finalName}.jar</include>
            </resource>
          </resources>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <configuration>
              <tasks>
                <copy todir="src/main/docker" file="target/${project.artifactId}-${project.version}.${project.packaging}"></copy>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

(2) 在src/main目錄下創(chuàng)建docker目錄,并創(chuàng)建Dockerfile文件

FROM openjdk:8-jdk-alpine
ADD *.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

(3) 在resource目錄下創(chuàng)建application.properties文件

logging.config=classpath:logback.xml
logging.path=/home/developer/app/logs/
server.port=8990

(4) 創(chuàng)建DockerApplication文件

@SpringBootApplication
public class DockerApplication {
 public static void main(String[] args) {
 SpringApplication.run(DockerApplication.class, args);
 }
}

(5) 創(chuàng)建DockerController文件

@RestController
public class DockerController {
 static Log log = LogFactory.getLog(DockerController.class);
 @RequestMapping("/")
 public String index() {
 log.info("Hello Docker!");
 return "Hello Docker!";
 }
}

(6) 增加配置

命令解釋

Image tag : 指定鏡像名稱(chēng)和tag,鏡像名稱(chēng)為 docker-demo,tag為1.1

Bind ports : 綁定宿主機(jī)端口到容器內(nèi)部端口。格式為[宿主機(jī)端口]:[容器內(nèi)部端口]

Bind mounts : 將宿主機(jī)目錄掛到到容器內(nèi)部目錄中。格式為[宿主機(jī)目錄](méi):[容器內(nèi)部目錄](méi)

這個(gè)springboot項(xiàng)目會(huì)將日志打印在容器 /home/developer/app/logs/ 目錄下,將宿主機(jī)目錄掛載到容器內(nèi)部目錄后,那么日志就會(huì)持久化容器外部的宿主機(jī)目錄中。

(7) Maven打包

(8) 運(yùn)行

這里我們可以看到鏡像名稱(chēng)為docker-demo:1.1,docker容器為docker-server

(9) 運(yùn)行成功

(10) 瀏覽器訪(fǎng)問(wèn)

(11) 日志查看

自此通過(guò)idea 部署springboot項(xiàng)目到docker成功!難以想象,部署一個(gè)Javaweb項(xiàng)目竟然如此簡(jiǎn)單方便!

最后分享給大家相關(guān)學(xué)習(xí)教程👇:

https://www.bilibili.com/video/BV14t411z77T

IDEA教程

https://www.bilibili.com/video/BV1PZ4y1j7QK

到此這篇關(guān)于Docker遇到Intellij IDEA,Java開(kāi)發(fā)提升了十倍生產(chǎn)力的文章就介紹到這了,更多相關(guān)Docker遇到 IDEA內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • docker for windonws之Windows 10 家庭中文版安裝clickhouse 22.3版本及配置過(guò)程

    docker for windonws之Windows 10 家庭中文版安裝cl

    這篇文章主要介紹了docker for windonws之Windows 10 家庭中文版安裝clickhouse 22.3版本及配置,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-08-08
  • CentOS7部署19版docker(簡(jiǎn)單,可跟做)

    CentOS7部署19版docker(簡(jiǎn)單,可跟做)

    這篇文章主要介紹了CentOS7部署19版docker,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • 使用docker部署dubbo項(xiàng)目的方法步驟

    使用docker部署dubbo項(xiàng)目的方法步驟

    這篇文章主要介紹了使用docker部署dubbo項(xiàng)目的方法步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • 關(guān)于docker安裝python3.8鏡像的問(wèn)題

    關(guān)于docker安裝python3.8鏡像的問(wèn)題

    這篇文章主要介紹了docker安裝python3.8鏡像的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-10-10
  • IDEA 通過(guò)docker插件發(fā)布springboot項(xiàng)目的詳細(xì)教程

    IDEA 通過(guò)docker插件發(fā)布springboot項(xiàng)目的詳細(xì)教程

    這篇文章主要介紹了IDEA 通過(guò)docker插件發(fā)布springboot項(xiàng)目的詳細(xì)教程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-09-09
  • Docker容器應(yīng)用中,10個(gè)要不得的壞習(xí)慣

    Docker容器應(yīng)用中,10個(gè)要不得的壞習(xí)慣

    這篇文章主要介紹了Docker容器的應(yīng)用中,10個(gè)要不得的壞習(xí)慣,幫助大家更好的理解和使用docker,感興趣的朋友可以了解下
    2020-08-08
  • 詳解docker搭建redis集群的環(huán)境搭建

    詳解docker搭建redis集群的環(huán)境搭建

    本篇文章主要介紹了詳解docker搭建redis集群的環(huán)境搭建,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-07-07
  • 解決docker數(shù)據(jù)文件過(guò)大導(dǎo)致根磁盤(pán)滿(mǎn)的問(wèn)題

    解決docker數(shù)據(jù)文件過(guò)大導(dǎo)致根磁盤(pán)滿(mǎn)的問(wèn)題

    本篇文章主要介紹了解決docker數(shù)據(jù)文件過(guò)大導(dǎo)致根磁盤(pán)滿(mǎn)的問(wèn)題,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-04-04
  • docker?build運(yùn)行報(bào)錯(cuò)source:?not?found解決分析

    docker?build運(yùn)行報(bào)錯(cuò)source:?not?found解決分析

    這篇文章主要為大家介紹了docker?build運(yùn)行報(bào)錯(cuò)source:?not?found解決分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-09-09
  • 詳解CentOS 7 : Docker私有倉(cāng)庫(kù)搭建和使用

    詳解CentOS 7 : Docker私有倉(cāng)庫(kù)搭建和使用

    本篇文章主要介紹了詳解CentOS 7 : Docker私有倉(cāng)庫(kù)搭建和使用,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-02-02

最新評(píng)論