Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

IDEA2021.2 configure docker how to mirror the springboot project and release deployment with one click

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

In this issue, the editor will bring you about IDEA2021.2 configuration docker how to mirror the springboot project and release deployment. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.

Here is how to configure docker in IDEA to deploy the project to the server

Idea2021 Activation tutorial

Https://www.yuque.com/docs/share/b996d27e-c888-45f2-bb1e-f6db5efe2485?#

Https://www.yisu.com/article/178193.htm

Go to the plug-in center to install the Docker plug-in and restart IDEA after installation. This is simple.

Configure the connection remote docker, open the Docker plug-in, create a new connection, and enter the server IP address at Engine API URL: 2375. Connection successful indicates that the link is successful, otherwise you need to see whether the ip port is open.

Create a new springboot project, docker-maven-plugin the plug-in in the pom file, and copy it directly

Com.spotify docker-maven-plugin 1.2.1 build-image package build Clover/$ {project.artifactId} latest ${project.basedir} / src/main/resources/docker Http://192.168.6.215:2375 / ${project.build.directory} ${project.build.finalName} .jar

Add a url interface to facilitate access to:

SpringBootApplication (exclude= {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) @ RestControllerpublic class DockerdemoApplication {public static void main (String [] args) {SpringApplication.run (DockerdemoApplication.class, args);} @ RequestMapping ("/ test") public String test () {return "1. Hello world!" + new SimpleDateFormat ("[yyyy-mm-dd HH:mm:ss]") .format (new Date ());}}

Create a new Dockerfile file in the project root directory

# Docker image for springboot application# VERSION 0.0.roomAuthor: bolingcavalry### basic image. Using the alpine operating system, openjkd declares a mount point using 8u201FROM openjdk:8u201-jdk-alpine3.9# author MAINTAINER BolingCavalry # system coding ENV LANG=C.UTF-8 LC_ALL=C.UTF-8#. This path in the container will correspond to a folder of the host, and the jar file after the successful construction of the VOLUME / tmp# application is copied to the image. The name has also been changed to the process ENTRYPOINT when app.jarADD target/dockerplugindemo-0.0.1-SNAPSHOT.jar app.jar# starts the container ["java", "- jar", "/ app.jar"] # exposing port 8080 EXPOSE 8080

Create a new dockerfile startup file in IDEA

The Dockerfile configuration details are shown in the following figure. Please follow the instructions in the figure to ensure that each red box will be executed to:

After clicking "Run Maven Goal" at the bottom of the image above, a small window will pop up to enter the maven command to be executed. Enter clean package-U-DskipTests here, indicating that each time before building the image, the current project will be cleaned up and the build will be recompiled:

When the settings are complete, click the green triangle button in the red box below to perform this configuration:

The release is not successful because the idea is not opened by the administrator. The author encountered this situation, the release failed and could not connect to the server docker. Or firewall, the port of the host is not written correctly, and so on.

Execute docker image on the server to view the image

Access the address: http://192.168.6.215:8080/test on the browser and get the response as shown in the following figure. It can be seen that the application is running normally in the container:

If you modify the code, click the triangle above to start again, and the deployment will be released again.

The above is the IDEA2021.2 configuration docker shared by Xiaobian how to release and deploy the springboot project as a mirror. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report