码头工人如何部署springboot项目

  介绍

这篇文章主要为大家展示了“码头工人如何部署springboot项目”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“码头工人如何部署springboot项目”这篇文章吧。

<强>创建项目

砰的一声。xml

& lt; ? xml  version=?.0“,编码=癠TF-8" ?比;   & lt; project  xmlns=癶ttp://maven.apache.org/POM/4.0.0", xmlns: xsi=癶ttp://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"比;   & lt;才能modelVersion> 4.0.0</modelVersion>   & lt;才能parent>   ,,,& lt; groupId> org.springframework.boot   ,,,& lt; artifactId> spring-boot-starter-parent   ,,,& lt; version> 2.1.9.RELEASE   ,,,& lt; relativePath/祝辞,& lt; !——, lookup  parent 得到repository ——比;   & lt;才能/parent>   & lt;才能groupId> com.topcheer</groupId>   & lt;才能artifactId> docker</artifactId>   & lt;才能version> 0.0.1-SNAPSHOT</version>   & lt;才能name> docker</name>   & lt;才能description> Demo  project  for  Spring  Boot      & lt;才能properties>   ,,,& lt; java.version> 1.8 & lt;/java.version>   ,,,& lt; docker.image.prefix> topcheer   & lt;才能/properties>      & lt;才能dependencies>   ,,,& lt; dependency>   ,,,,,& lt; groupId> org.springframework.boot   ,,,,,& lt; artifactId> spring-boot-starter-web   ,,,& lt;/dependency>      ,,,& lt; dependency>   ,,,,,& lt; groupId> org.springframework.boot   ,,,,,& lt; artifactId> spring-boot-starter-test   ,,,,,& lt; scope> test   ,,,& lt;/dependency>   & lt;才能/dependencies>      & lt;才能build>   ,,,& lt; plugins>   ,,,,,& lt; plugin>   ,,,,,,,& lt; groupId> org.springframework.boot   ,,,,,,,& lt; artifactId> spring-boot-maven-plugin   ,,,,,& lt;/plugin>   ,,,,,,& lt; plugin>   ,,,,,& lt; groupId> com.spotify   ,,,,,& lt; artifactId> docker-maven-plugin   ,,,,,& lt; version> 1.0.0   ,,,,,& lt; configuration>   ,,,,,,,& lt; imageName> $ {docker.image.prefix}/{project.artifactId} & lt;美元/imageName>   ,,,,,,,& lt; dockerDirectory> src/主/docker   ,,,,,,,& lt; resources>   ,,,,,,,,,& lt; resource>   ,,,,,,,,,,,& lt; targetPath>/& lt;/targetPath>   ,,,,,,,,,,,& lt; directory> $ {project.build.directory} & lt;/directory>   ,,,,,,,,,,,& lt; include> $ {project.build.finalName} .jar   ,,,,,,,,,& lt;/resource>   ,,,,,,,& lt;/resources>   ,,,,,& lt;/configuration>   ,,,& lt;/plugin>   ,,,& lt;/plugins>   & lt;才能/build>      & lt;/project>

<>强启动类

@SpringBootApplication   @ controller   public  class  DockerApplication  {   public 才能;static  void  main (String [], args), {   ,,,SpringApplication.run (DockerApplication.class, args);   ,,}   @RequestMapping才能(“/user/find")   @ResponseBody才能   public 才能;Object  findUser () {   ,,,Map<字符串,String 祝辞,map =, new  HashMap<在();   ,,,map.put (“name",,“xdclass.net");   ,,,map.put (“age"“28”);   ,,,return 地图;   ,,}   }

由于港没有安装,无法把镜像推到私有镜像仓库上,所以先手动执行。

mvn install,然后把dockerfile和jar包放到一起

[root@topcheer 码头工人]#,你   总用量,16452   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

码头工人如何部署springboot项目