In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail what matters needing attention for IDEA to cooperate with Dockerfile to deploy SpringBoot project. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Prepare the SpringBoot project
1. New SpringBoot project, default port is 8080, new Controller and Mapping
RestControllerpublic class HelloController {@ GetMapping ("hello") public String hello () {return "hello world!";}}
Note that you need to add the spring-boot-maven-plugin plug-in to pom, otherwise you will be prompted when you run the jar package: there is no main manifest property
Org.springframework.boot spring-boot-maven-plugin
Start the project and access the http://localhost:8080/hello test
two。 Add Dockerfile files to the project directory
FROM openjdk:8-jre#. / target/demo-0.0.1-SNAPSHOT.jar is the location of the compiled jar package. The name of the jar package should be the same as the one you configured. The format is: project name-version number .jarCOPY. / target/demo-0.0.1-SNAPSHOT.jar app.jarEXPOSE 8080ENTRYPOINT ["java", "- jar"] CMD ["app.jar"]
3.Docker remote connection configuration
The Docker host used in the demonstration is CentOS 7. Modify the configuration and restart the Docker service.
Vim / lib/systemd/system/docker.service
Change the ExecStar line configuration to the following line
ExecStart=/usr/bin/dockerd-H unix:///var/run/docker.sock-H tcp://0.0.0.0:2375
Restart the service
Systemctl daemon-reloadsystemctl restart docker
You can test by accessing API. The IP needs to be modified to the IP corresponding to the host, and the port is set to 2375. If the access is successful, the relevant version information of Docker Engine will be displayed.
Http://192.168.43.161:2375/version
If you are deployed in a public network or production environment, you need to configure security access. For more information, please see: Docker enables remote security access.
IDEA configuration
IDEA installs the Docker plug-in
Configure IDEA Docker connection
Docker can be found in the settings, click the plus sign to add a new Docker connection, enter the name, Engine API URL, and then prompt: Connection successful, that is, the connection is successful
Click Run/Debug Configurations
Enter name, add Dockerfile (the one you just added), container name, mapping port number
Before launch selects Maven and enters the command: clean package-U-DskipTests, which runs each time Dockerfile is compiled
Click run to automatically type the jar package, build an image on the host, and run the container.
You can test access through the Docker host. The 192.168.43.161 shown here needs to be replaced with the IP of your own Docker host.
Http://192.168.43.161:8080/hello
This is the end of this article on "what are the precautions for IDEA to cooperate with Dockerfile to deploy the SpringBoot project". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.