当前位置:   article > 正文

maven管理的spring-boot的web项目启动的三种方式【mvn命令~~~IDEA工具~~Jar启动】

maven管理的spring-boot的web项目启动的三种方式【mvn命令~~~IDEA工具~~Jar启动】

可以参考项目地址 :https://github.com/burnszp/springbootvue.git

一、使用Maven命令启动

1、进入项目的根目录下:

  1. D:\work\ideaProject>cd springbootvue
  2. D:\work\ideaProject\springbootvue>cd chapter01
  3. D:\work\ideaProject\springbootvue\chapter01>

2、输入如下命令

mvn spring-boot:run

D:\work\ideaProject\springbootvue\chapter01>mvn spring-boot:run

执行如下:

  1. D:\work\ideaProject\springbootvue\chapter01>mvn spring-boot:run
  2. [INFO] Scanning for projects...
  3. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-
  4. maven-plugin-1.2.51.pom
  5. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-m
  6. aven-plugin-1.2.51.pom (6 KB at 9.9 KB/sec)
  7. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-project/1.2.51/kotlin-proje
  8. ct-1.2.51.pom
  9. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-project/1.2.51/kotlin-projec
  10. t-1.2.51.pom (10 KB at 68.8 KB/sec)
  11. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-
  12. maven-plugin-1.2.51.jar
  13. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-m
  14. aven-plugin-1.2.51.jar (77 KB at 403.0 KB/sec)
  15. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-codegen-maven/3.10.8/jooq-codegen-maven-3
  16. .10.8.pom
  17. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-codegen-maven/3.10.8/jooq-codegen-maven-3.
  18. 10.8.pom (4 KB at 16.0 KB/sec)
  19. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-parent/3.10.8/jooq-parent-3.10.8.pom
  20. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-parent/3.10.8/jooq-parent-3.10.8.pom (11 K
  21. B at 77.8 KB/sec)
  22. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-codegen-maven/3.10.8/jooq-codegen-maven-3
  23. .10.8.jar
  24. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-codegen-maven/3.10.8/jooq-codegen-maven-3.
  25. 10.8.jar (16 KB at 68.1 KB/sec)
  26. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-maven-plugin/2.0.4
  27. .RELEASE/spring-boot-maven-plugin-2.0.4.RELEASE.pom
  28. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-maven-plugin/2.0.4.
  29. RELEASE/spring-boot-maven-plugin-2.0.4.RELEASE.pom (0 B at 0.0 KB/sec)
  30. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-tools/2.0.4.RELEAS
  31. E/spring-boot-tools-2.0.4.RELEASE.pom
  32. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-tools/2.0.4.RELEASE
  33. /spring-boot-tools-2.0.4.RELEASE.pom (0 B at 0.0 KB/sec)
  34. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-maven-plugin/2.0.4
  35. .RELEASE/spring-boot-maven-plugin-2.0.4.RELEASE.jar
  36. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-maven-plugin/2.0.4.
  37. RELEASE/spring-boot-maven-plugin-2.0.4.RELEASE.jar (0 B at 0.0 KB/sec)
  38. [INFO]
  39. [INFO] ------------------------------------------------------------------------
  40. [INFO] Building chapter01 1.0-SNAPSHOT
  41. [INFO] ------------------------------------------------------------------------
  42. [INFO]
  43. [INFO] >>> spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) > test-compile @ chapter01 >>>
  44. [INFO]
  45. [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ chapter01 ---
  46. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  47. [INFO] Copying 0 resource
  48. [INFO] Copying 0 resource
  49. [INFO]
  50. [INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ chapter01 ---
  51. [INFO] Changes detected - recompiling the module!
  52. [INFO] Compiling 2 source files to D:\work\ideaProject\springbootvue\chapter01\target\classes
  53. [INFO]
  54. [INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ chapter01 ---
  55. [INFO] Using 'UTF-8' encoding to copy filtered resources.
  56. [INFO] skip non existing resourceDirectory D:\work\ideaProject\springbootvue\chapter01\src\test\resources
  57. [INFO]
  58. [INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ chapter01 ---
  59. [INFO] Nothing to compile - all classes are up to date
  60. [INFO]
  61. [INFO] <<< spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) < test-compile @ chapter01 <<<
  62. [INFO]
  63. [INFO] --- spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) @ chapter01 ---
  64. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.0.4
  65. .RELEASE/spring-boot-loader-tools-2.0.4.RELEASE.pom
  66. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.0.4.
  67. RELEASE/spring-boot-loader-tools-2.0.4.RELEASE.pom (0 B at 0.0 KB/sec)
  68. Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.0.4
  69. .RELEASE/spring-boot-loader-tools-2.0.4.RELEASE.jar
  70. Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.0.4.
  71. RELEASE/spring-boot-loader-tools-2.0.4.RELEASE.jar (0 B at 0.0 KB/sec)
  72. . ____ _ __ _ _
  73. /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  74. ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  75. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  76. ' |____| .__|_| |_|_| |_\__, | / / / /
  77. =========|_|==============|___/=/_/_/_/
  78. :: Spring Boot :: (v2.0.4.RELEASE)
  79. 2020-03-02 17:59:11.545 INFO 13280 --- [ main] com.burns.ch1.Chapter01App : Starting Chapter01A
  80. pp on DESKTOP-LOQT6LN with PID 13280 (D:\work\ideaProject\springbootvue\chapter01\target\classes started by 35725 in D:\
  81. work\ideaProject\springbootvue\chapter01)
  82. 2020-03-02 17:59:11.549 INFO 13280 --- [ main] com.burns.ch1.Chapter01App : No active profile s
  83. et, falling back to default profiles: default
  84. 2020-03-02 17:59:11.607 INFO 13280 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.spri
  85. ngframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1f9d938a: startup date [Mon Mar
  86. 02 17:59:11 CST 2020]; root of context hierarchy
  87. 2020-03-02 17:59:12.899 INFO 13280 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized
  88. with port(s): 8080 (http)
  89. 2020-03-02 17:59:12.938 INFO 13280 --- [ main] o.apache.catalina.core.StandardService : Starting service [T
  90. omcat]
  91. 2020-03-02 17:59:12.939 INFO 13280 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet En
  92. gine: Apache Tomcat/8.5.32
  93. 2020-03-02 17:59:12.953 INFO 13280 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apach
  94. e Tomcat Native library which allows optimal performance in production environments was not found on the java.library.pa
  95. th: [C:\program\Java\jdk1.8_121\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\MentorGraphics\CHS2019\jre
  96. \bin;C:\MentorGraphics\CHS2019\bin;C:\MentorGraphics\CHS2019\jreWin64\1.8.0_202\jre\bin\server;C:\MentorGraphics\CHS2019
  97. \jreWin64\1.8.0_202\jre\bin;C:\program\Java\jdk1.8_121\bin;C:\MentorGraphics\CHS2013\bin;C:\MentorGraphics\CHS2013\jre\b
  98. in;C:\MentorGraphics\CHS2013\jre\bin\client;C:\MentorGraphics\CHS2012\bin;C:\MentorGraphics\CHS2012\jre\bin;C:\MentorGra
  99. phics\CHS2012\jre\bin\client;C:\MentorGraphics\CHS2017\bin;C:\MentorGraphics\CHS2017\jre\bin;C:\MentorGraphics\CHS2017\j
  100. re\bin\client;C:\MentorGraphics\CHS2011\bin;C:\MentorGraphics\CHS2011\jre\bin;C:\MentorGraphics\CHS2011\jre\bin\client;C
  101. :\MentorGraphics\CHS2016\bin;C:\MentorGraphics\CHS2016\jre\bin;C:\MentorGraphics\CHS2016\jre\bin\client;C:\MentorGraphic
  102. s\CHS2010\bin;C:\MentorGraphics\CHS2010\jre\bin;C:\MentorGraphics\CHS2010\jre\bin\client;C:\MentorGraphics\CHS2014\bin;C
  103. :\MentorGraphics\CHS2014\jre\bin;C:\MentorGraphics\CHS2014\jre\bin\client;C:\app\35725\product\11.2.0\dbhome_1\bin;C:\WI
  104. NDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenS
  105. SH\;C:\programs\apache-maven-3.3.9\bin;C:\programs\apache-ant-1.6.4\bin;C:\programs\NSIS\Bin;C:\Program Files\MySQL\MySQ
  106. L Utilities 1.6\;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\programs\Git\cmd;C:\programs\tomcat\apache-tomcat-6.0.33
  107. \bin;C:\programs\apache-cxf-2.3.0\bin;C:\Program Files\nodejs\;C:\Program Files\PowerShell\6\;C:\Users\35725\AppData\Loc
  108. al\Microsoft\WindowsApps;C:\Users\35725\AppData\Local\BypassRuntm;C:\Users\35725\AppData\Local\Programs\Microsoft VS Cod
  109. e\bin;C:\Users\35725\AppData\Roaming\npm;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;;.]
  110. 2020-03-02 17:59:13.062 INFO 13280 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring
  111. embedded WebApplicationContext
  112. 2020-03-02 17:59:13.063 INFO 13280 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplication
  113. Context: initialization completed in 1456 ms
  114. 2020-03-02 17:59:13.143 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherS
  115. ervlet mapped to [/]
  116. 2020-03-02 17:59:13.149 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'ch
  117. aracterEncodingFilter' to: [/*]
  118. 2020-03-02 17:59:13.151 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hi
  119. ddenHttpMethodFilter' to: [/*]
  120. 2020-03-02 17:59:13.152 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'ht
  121. tpPutFormContentFilter' to: [/*]
  122. 2020-03-02 17:59:13.157 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 're
  123. questContextFilter' to: [/*]
  124. 2020-03-02 17:59:13.288 INFO 13280 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/*
  125. */favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  126. 2020-03-02 17:59:13.459 INFO 13280 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @Contro
  127. llerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1f9d938a: st
  128. artup date [Mon Mar 02 17:59:11 CST 2020]; root of context hierarchy
  129. 2020-03-02 17:59:13.536 INFO 13280 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello],m
  130. ethods=[GET]}" onto public java.lang.String com.burns.ch1.controller.HelloConstroller.hello()
  131. 2020-03-02 17:59:13.540 INFO 13280 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}"
  132. onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframew
  133. ork.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
  134. 2020-03-02 17:59:13.543 INFO 13280 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],p
  135. roduces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.we
  136. b.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletRespo
  137. nse)
  138. 2020-03-02 17:59:13.572 INFO 13280 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/w
  139. ebjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  140. 2020-03-02 17:59:13.573 INFO 13280 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/*
  141. *] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  142. 2020-03-02 17:59:13.717 INFO 13280 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans f
  143. or JMX exposure on startup
  144. 2020-03-02 17:59:13.783 INFO 13280 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on p
  145. ort(s): 8080 (http) with context path ''
  146. 2020-03-02 17:59:13.788 INFO 13280 --- [ main] com.burns.ch1.Chapter01App : Started Chapter01Ap
  147. p in 2.787 seconds (JVM running for 10.964)
  148. 2020-03-02 18:00:06.620 INFO 13280 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring
  149. FrameworkServlet 'dispatcherServlet'
  150. 2020-03-02 18:00:06.623 INFO 13280 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'd
  151. ispatcherServlet': initialization started
  152. 2020-03-02 18:00:06.645 INFO 13280 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'd
  153. ispatcherServlet': initialization completed in 21 ms

3、浏览器访问http://localhost:8080/hello

4、程序终止的时候按Ctrl+C即可

  1. xposed beans on shutdown
  2. [INFO] ------------------------------------------------------------------------
  3. [INFO] BUILD SUCCESS终止批处理操作吗(Y/N)? Y
  4. D:\work\ideaProject\springbootvue\chapter01>

二、直接运行入口程序的main方法

这个就需要借助IDE工具了,eclipse或IDEA都可以,这里以IDEA为例

1、入口main方法

  1. package com.burns.ch1;
  2. import org.springframework.boot.SpringApplication;
  3. import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5. import org.springframework.context.annotation.ComponentScan;
  6. //@EnableAutoConfiguration
  7. //@ComponentScan
  8. @SpringBootApplication
  9. public class Chapter01App {
  10. public static void main(String[] args){
  11. SpringApplication.run(Chapter01App.class,args);
  12. }
  13. }

2、启动过程:

  1. C:\program\Java\jdk1.8_121\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=51861 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\programs\JetBrains\IntelliJ IDEA 2018.3.2\lib\idea_rt.jar=51862:C:\programs\JetBrains\IntelliJ IDEA 2018.3.2\bin" -Dfile.encoding=UTF-8 -classpath C:\program\Java\jdk1.8_121\jre\lib\charsets.jar;C:\program\Java\jdk1.8_121\jre\lib\deploy.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\access-bridge-64.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\cldrdata.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\dnsns.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\jaccess.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\jfxrt.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\localedata.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\nashorn.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\sunec.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\sunjce_provider.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\sunmscapi.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\sunpkcs11.jar;C:\program\Java\jdk1.8_121\jre\lib\ext\zipfs.jar;C:\program\Java\jdk1.8_121\jre\lib\javaws.jar;C:\program\Java\jdk1.8_121\jre\lib\jce.jar;C:\program\Java\jdk1.8_121\jre\lib\jfr.jar;C:\program\Java\jdk1.8_121\jre\lib\jfxswt.jar;C:\program\Java\jdk1.8_121\jre\lib\jsse.jar;C:\program\Java\jdk1.8_121\jre\lib\management-agent.jar;C:\program\Java\jdk1.8_121\jre\lib\plugin.jar;C:\program\Java\jdk1.8_121\jre\lib\resources.jar;C:\program\Java\jdk1.8_121\jre\lib\rt.jar;D:\work\ideaProject\springbootvue\chapter01\target\classes;C:\Users\35725\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.0.4.RELEASE\spring-boot-starter-web-2.0.4.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\boot\spring-boot-starter\2.0.4.RELEASE\spring-boot-starter-2.0.4.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\boot\spring-boot\2.0.4.RELEASE\spring-boot-2.0.4.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.4.RELEASE\spring-boot-autoconfigure-2.0.4.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.0.4.RELEASE\spring-boot-starter-logging-2.0.4.RELEASE.jar;C:\Users\35725\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\35725\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\35725\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\35725\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;C:\Users\35725\.m2\repository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;C:\Users\35725\.m2\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;C:\Users\35725\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\35725\.m2\repository\org\springframework\spring-core\5.0.8.RELEASE\spring-core-5.0.8.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\spring-jcl\5.0.8.RELEASE\spring-jcl-5.0.8.RELEASE.jar;C:\Users\35725\.m2\repository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;C:\Users\35725\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.0.4.RELEASE\spring-boot-starter-json-2.0.4.RELEASE.jar;C:\Users\35725\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;C:\Users\35725\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\35725\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;C:\Users\35725\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.6\jackson-datatype-jdk8-2.9.6.jar;C:\Users\35725\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.6\jackson-datatype-jsr310-2.9.6.jar;C:\Users\35725\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.6\jackson-module-parameter-names-2.9.6.jar;C:\Users\35725\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.0.4.RELEASE\spring-boot-starter-tomcat-2.0.4.RELEASE.jar;C:\Users\35725\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.32\tomcat-embed-core-8.5.32.jar;C:\Users\35725\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.32\tomcat-embed-el-8.5.32.jar;C:\Users\35725\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.32\tomcat-embed-websocket-8.5.32.jar;C:\Users\35725\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.11.Final\hibernate-validator-6.0.11.Final.jar;C:\Users\35725\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\35725\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\35725\.m2\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;C:\Users\35725\.m2\repository\org\springframework\spring-web\5.0.8.RELEASE\spring-web-5.0.8.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\spring-beans\5.0.8.RELEASE\spring-beans-5.0.8.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\spring-webmvc\5.0.8.RELEASE\spring-webmvc-5.0.8.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\spring-aop\5.0.8.RELEASE\spring-aop-5.0.8.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\spring-context\5.0.8.RELEASE\spring-context-5.0.8.RELEASE.jar;C:\Users\35725\.m2\repository\org\springframework\spring-expression\5.0.8.RELEASE\spring-expression-5.0.8.RELEASE.jar com.burns.ch1.Chapter01App
  2. . ____ _ __ _ _
  3. /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  4. ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  5. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  6. ' |____| .__|_| |_|_| |_\__, | / / / /
  7. =========|_|==============|___/=/_/_/_/
  8. :: Spring Boot :: (v2.0.4.RELEASE)
  9. 2020-03-02 18:13:21.075 INFO 9672 --- [ main] com.burns.ch1.Chapter01App : Starting Chapter01App on DESKTOP-LOQT6LN with PID 9672 (D:\work\ideaProject\springbootvue\chapter01\target\classes started by 35725 in D:\work\ideaProject\springbootvue\chapter01)
  10. 2020-03-02 18:13:21.078 INFO 9672 --- [ main] com.burns.ch1.Chapter01App : No active profile set, falling back to default profiles: default
  11. 2020-03-02 18:13:21.139 INFO 9672 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@13acb0d1: startup date [Mon Mar 02 18:13:21 CST 2020]; root of context hierarchy
  12. 2020-03-02 18:13:22.372 INFO 9672 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
  13. 2020-03-02 18:13:22.395 INFO 9672 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
  14. 2020-03-02 18:13:22.396 INFO 9672 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.32
  15. 2020-03-02 18:13:22.400 INFO 9672 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\program\Java\jdk1.8_121\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\MentorGraphics\CHS2019\jre\bin;C:\MentorGraphics\CHS2019\bin;C:\MentorGraphics\CHS2019\jreWin64\1.8.0_202\jre\bin\server;C:\MentorGraphics\CHS2019\jreWin64\1.8.0_202\jre\bin;C:\program\Java\jdk1.8_121\bin;C:\MentorGraphics\CHS2013\bin;C:\MentorGraphics\CHS2013\jre\bin;C:\MentorGraphics\CHS2013\jre\bin\client;C:\MentorGraphics\CHS2012\bin;C:\MentorGraphics\CHS2012\jre\bin;C:\MentorGraphics\CHS2012\jre\bin\client;C:\MentorGraphics\CHS2017\bin;C:\MentorGraphics\CHS2017\jre\bin;C:\MentorGraphics\CHS2017\jre\bin\client;C:\MentorGraphics\CHS2011\bin;C:\MentorGraphics\CHS2011\jre\bin;C:\MentorGraphics\CHS2011\jre\bin\client;C:\MentorGraphics\CHS2016\bin;C:\MentorGraphics\CHS2016\jre\bin;C:\MentorGraphics\CHS2016\jre\bin\client;C:\MentorGraphics\CHS2010\bin;C:\MentorGraphics\CHS2010\jre\bin;C:\MentorGraphics\CHS2010\jre\bin\client;C:\MentorGraphics\CHS2014\bin;C:\MentorGraphics\CHS2014\jre\bin;C:\MentorGraphics\CHS2014\jre\bin\client;C:\app\35725\product\11.2.0\dbhome_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\programs\apache-maven-3.3.9\bin;C:\programs\apache-ant-1.6.4\bin;C:\programs\NSIS\Bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\programs\Git\cmd;C:\programs\tomcat\apache-tomcat-6.0.33\bin;C:\programs\apache-cxf-2.3.0\bin;C:\Program Files\nodejs\;C:\Program Files\PowerShell\6\;C:\Users\35725\AppData\Local\Microsoft\WindowsApps;C:\Users\35725\AppData\Local\BypassRuntm;C:\Users\35725\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\35725\AppData\Roaming\npm;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;;.]
  16. 2020-03-02 18:13:22.480 INFO 9672 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  17. 2020-03-02 18:13:22.481 INFO 9672 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1341 ms
  18. 2020-03-02 18:13:22.533 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
  19. 2020-03-02 18:13:22.538 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
  20. 2020-03-02 18:13:22.538 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
  21. 2020-03-02 18:13:22.538 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
  22. 2020-03-02 18:13:22.538 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
  23. 2020-03-02 18:13:22.620 INFO 9672 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  24. 2020-03-02 18:13:22.793 INFO 9672 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@13acb0d1: startup date [Mon Mar 02 18:13:21 CST 2020]; root of context hierarchy
  25. 2020-03-02 18:13:22.843 INFO 9672 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello],methods=[GET]}" onto public java.lang.String com.burns.ch1.controller.HelloConstroller.hello()
  26. 2020-03-02 18:13:22.847 INFO 9672 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
  27. 2020-03-02 18:13:22.848 INFO 9672 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
  28. 2020-03-02 18:13:22.872 INFO 9672 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  29. 2020-03-02 18:13:22.873 INFO 9672 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  30. 2020-03-02 18:13:23.004 INFO 9672 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
  31. 2020-03-02 18:13:23.034 INFO 9672 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
  32. 2020-03-02 18:13:23.038 INFO 9672 --- [ main] com.burns.ch1.Chapter01App : Started Chapter01App in 2.534 seconds (JVM running for 3.959)

3、浏览器访问:

参考第一种情况

 

三、打Jar包运行

1、添加plugins到pom.xml中

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.springframework.boot</groupId>
  5. <artifactId>spring-boot-maven-plugin</artifactId>
  6. </plugin>
  7. </plugins>
  8. </build>

完整的pom.xml如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <groupId>com.burns</groupId>
  7. <artifactId>chapter01</artifactId>
  8. <version>1.0-SNAPSHOT</version>
  9. <parent>
  10. <groupId>org.springframework.boot</groupId>
  11. <artifactId>spring-boot-starter-parent</artifactId>
  12. <version>2.0.4.RELEASE</version>
  13. </parent>
  14. <dependencies>
  15. <dependency>
  16. <groupId>org.springframework.boot</groupId>
  17. <artifactId>spring-boot-starter-web</artifactId>
  18. </dependency>
  19. </dependencies>
  20. <build>
  21. <plugins>
  22. <plugin>
  23. <groupId>org.springframework.boot</groupId>
  24. <artifactId>spring-boot-maven-plugin</artifactId>
  25. </plugin>
  26. </plugins>
  27. </build>
  28. </project>

2、运行maven命令进行打包

在target目录下有一个jar文件生成:

3、命令行运行java -jar chapter01-1.0-SNAPSHOT.jar

 

  1. D:\work\ideaProject\springbootvue\chapter01\target>java -jar chapter01-1.0-SNAPSHOT.jar
  2. . ____ _ __ _ _
  3. /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
  4. ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  5. \\/ ___)| |_)| | | | | || (_| | ) ) ) )
  6. ' |____| .__|_| |_|_| |_\__, | / / / /
  7. =========|_|==============|___/=/_/_/_/
  8. :: Spring Boot :: (v2.0.4.RELEASE)
  9. 2020-03-02 18:23:29.356 INFO 11360 --- [ main] com.burns.ch1.Chapter01App : Starting Chapter01App v1.0-SNAPSHOT on DESKTOP-LOQT6LN
  10. with PID 11360 (D:\work\ideaProject\springbootvue\chapter01\target\chapter01-1.0-SNAPSHOT.jar started by 35725 in D:\work\ideaProject\springbootvue\chapte
  11. r01\target)
  12. 2020-03-02 18:23:29.361 INFO 11360 --- [ main] com.burns.ch1.Chapter01App : No active profile set, falling back to default profile
  13. s: default
  14. 2020-03-02 18:23:29.437 INFO 11360 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.contex
  15. t.AnnotationConfigServletWebServerApplicationContext@7cef4e59: startup date [Mon Mar 02 18:23:29 CST 2020]; root of context hierarchy
  16. 2020-03-02 18:23:31.286 INFO 11360 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
  17. 2020-03-02 18:23:31.324 INFO 11360 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
  18. 2020-03-02 18:23:31.326 INFO 11360 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.32
  19. 2020-03-02 18:23:31.342 INFO 11360 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allow
  20. s optimal performance in production environments was not found on the java.library.path: [C:\MentorGraphics\CHS2019\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WIND
  21. OWS\system32;C:\WINDOWS;C:\MentorGraphics\CHS2019\jre\bin;C:\MentorGraphics\CHS2019\bin;C:\MentorGraphics\CHS2019\jreWin64\1.8.0_202\jre\bin\server;C:\Ment
  22. orGraphics\CHS2019\jreWin64\1.8.0_202\jre\bin;C:\program\Java\jdk1.8_121\bin;C:\MentorGraphics\CHS2013\bin;C:\MentorGraphics\CHS2013\jre\bin;C:\MentorGraph
  23. ics\CHS2013\jre\bin\client;C:\MentorGraphics\CHS2012\bin;C:\MentorGraphics\CHS2012\jre\bin;C:\MentorGraphics\CHS2012\jre\bin\client;C:\MentorGraphics\CHS20
  24. 17\bin;C:\MentorGraphics\CHS2017\jre\bin;C:\MentorGraphics\CHS2017\jre\bin\client;C:\MentorGraphics\CHS2011\bin;C:\MentorGraphics\CHS2011\jre\bin;C:\Mentor
  25. Graphics\CHS2011\jre\bin\client;C:\MentorGraphics\CHS2016\bin;C:\MentorGraphics\CHS2016\jre\bin;C:\MentorGraphics\CHS2016\jre\bin\client;C:\MentorGraphics\
  26. CHS2010\bin;C:\MentorGraphics\CHS2010\jre\bin;C:\MentorGraphics\CHS2010\jre\bin\client;C:\MentorGraphics\CHS2014\bin;C:\MentorGraphics\CHS2014\jre\bin;C:\M
  27. entorGraphics\CHS2014\jre\bin\client;C:\app\35725\product\11.2.0\dbhome_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\W
  28. indowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\programs\apache-maven-3.3.9\bin;C:\programs\apache-ant-1.6.4\bin;C:\programs\NSIS\Bin;C:\Program Fil
  29. es\MySQL\MySQL Utilities 1.6\;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\programs\Git\cmd;C:\programs\tomcat\apache-tomcat-6.0.33\bin;C:\programs\apach
  30. e-cxf-2.3.0\bin;C:\Program Files\nodejs\;C:\Program Files\PowerShell\6\;C:\Users\35725\AppData\Local\Microsoft\WindowsApps;C:\Users\35725\AppData\Local\Byp
  31. assRuntm;C:\Users\35725\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\35725\AppData\Roaming\npm;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;;
  32. .]
  33. 2020-03-02 18:23:31.465 INFO 11360 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
  34. 2020-03-02 18:23:31.466 INFO 11360 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed i
  35. n 2033 ms
  36. 2020-03-02 18:23:31.592 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
  37. 2020-03-02 18:23:31.602 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
  38. 2020-03-02 18:23:31.609 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
  39. 2020-03-02 18:23:31.621 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
  40. 2020-03-02 18:23:31.652 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
  41. 2020-03-02 18:23:31.813 INFO 11360 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type
  42. [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  43. 2020-03-02 18:23:32.109 INFO 11360 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boo
  44. t.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7cef4e59: startup date [Mon Mar 02 18:23:29 CST 2020]; root of context hierarchy
  45. 2020-03-02 18:23:32.242 INFO 11360 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello],methods=[GET]}" onto public java.lan
  46. g.String com.burns.ch1.controller.HelloConstroller.hello()
  47. 2020-03-02 18:23:32.250 INFO 11360 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.ht
  48. tp.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(ja
  49. vax.servlet.http.HttpServletRequest)
  50. 2020-03-02 18:23:32.253 INFO 11360 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public o
  51. rg.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.Http
  52. ServletRequest,javax.servlet.http.HttpServletResponse)
  53. 2020-03-02 18:23:32.290 INFO 11360 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [cl
  54. ass org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  55. 2020-03-02 18:23:32.291 INFO 11360 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.
  56. springframework.web.servlet.resource.ResourceHttpRequestHandler]
  57. 2020-03-02 18:23:32.481 INFO 11360 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
  58. 2020-03-02 18:23:32.549 INFO 11360 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context pa
  59. th ''
  60. 2020-03-02 18:23:32.555 INFO 11360 --- [ main] com.burns.ch1.Chapter01App : Started Chapter01App in 3.641 seconds (JVM running for
  61. 4.538)

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/237482
推荐阅读
相关标签
  

闽ICP备14008679号