In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how many ways to start springboot", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how many ways to start springboot" this article.
Environmental preparation
Create a project
Pom.xml content
4.0.0 cn.tx.springboot tx_demo2 0.0.1-SNAPSHOT jar tx_demo2 Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent 2.0.3.RELEASE UTF- 8 UTF-8 1.8 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot- Starter-test test org.springframework.boot spring-boot-maven-plugin
Launch class TxDemo2Application
@ SpringBootApplicationpublic class TxDemo2Application {public static void main (String [] args) {SpringApplication.run (TxDemo2Application.class, args);}}
Test class TestController
@ RestControllerpublic class TestController {@ RequestMapping ("/ hello") public String hello () {return "hello";}} first: direct main method to start TxDemo2Application
Test access
Second: start through the maven plug-in
Enter:
C:\ Users\ rlsl180506\ Desktop\ tx_demo2 > mvn spring-boot:run
Test access
The third is to access C:\ Users\ rlsl180506\ Desktop\ tx_demo2 > mvn clean package in a jar package.
Enter the path where jar is located to execute
C:\ Users\ rlsl180506\ Desktop\ tx_demo2\ target > java-jar tx_demo2-0.0.1-SNAPSHOT.jar
Test results:
The fourth method runs virtualized through the docker container
First of all, I'm going to be in the docker environment of linux. Secondly, copy the jar typed in step 3 to the specified directory under linux, and change the name to tx_demo2.jar
Mv tx_demo2-0.0.1-SNAPSHOT.jar tx_demo2.jar
Create a DockerFile file
FROM openjdk:8-jdk-alpineARG JAR_FILECOPY ${JAR_FILE} app.jarEXPOSE 10001ENTRYPOINT ["java", "- jar", "/ app.jar"]
Tx_demo2.jar and DockerFile build the image in the same path
Docker build--build-arg JAR_FILE=tx_demo2.jar-t tx_demo2:1.0.
Start the container:
Docker run-p 8080 8080 tx_demo2:1.0
Access test
The above is all the contents of the article "how many ways to start springboot". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.
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.