可以参考项目地址 :https://github.com/burnszp/springbootvue.git
一、使用Maven命令启动
1、进入项目的根目录下:
D:\work\ideaProject>cd springbootvue
D:\work\ideaProject\springbootvue>cd chapter01
D:\work\ideaProject\springbootvue\chapter01>
2、输入如下命令
mvn spring-boot:run
D:\work\ideaProject\springbootvue\chapter01>mvn spring-boot:run
执行如下:
D:\work\ideaProject\springbootvue\chapter01>mvn spring-boot:run
[INFO] Scanning for projects...
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-
maven-plugin-1.2.51.pom
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-m
aven-plugin-1.2.51.pom (6 KB at 9.9 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-project/1.2.51/kotlin-proje
ct-1.2.51.pom
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-project/1.2.51/kotlin-projec
t-1.2.51.pom (10 KB at 68.8 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-
maven-plugin-1.2.51.jar
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-m
aven-plugin-1.2.51.jar (77 KB at 403.0 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-codegen-maven/3.10.8/jooq-codegen-maven-3
.10.8.pom
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-codegen-maven/3.10.8/jooq-codegen-maven-3.
10.8.pom (4 KB at 16.0 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-parent/3.10.8/jooq-parent-3.10.8.pom
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-parent/3.10.8/jooq-parent-3.10.8.pom (11 K
B at 77.8 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-codegen-maven/3.10.8/jooq-codegen-maven-3
.10.8.jar
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/jooq/jooq-codegen-maven/3.10.8/jooq-codegen-maven-3.
10.8.jar (16 KB at 68.1 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-maven-plugin/2.0.4
.RELEASE/spring-boot-maven-plugin-2.0.4.RELEASE.pom
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-maven-plugin/2.0.4.
RELEASE/spring-boot-maven-plugin-2.0.4.RELEASE.pom (0 B at 0.0 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-tools/2.0.4.RELEAS
E/spring-boot-tools-2.0.4.RELEASE.pom
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-tools/2.0.4.RELEASE
/spring-boot-tools-2.0.4.RELEASE.pom (0 B at 0.0 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-maven-plugin/2.0.4
.RELEASE/spring-boot-maven-plugin-2.0.4.RELEASE.jar
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-maven-plugin/2.0.4.
RELEASE/spring-boot-maven-plugin-2.0.4.RELEASE.jar (0 B at 0.0 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building chapter01 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) > test-compile @ chapter01 >>>
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ chapter01 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ chapter01 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to D:\work\ideaProject\springbootvue\chapter01\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ chapter01 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\work\ideaProject\springbootvue\chapter01\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ chapter01 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) < test-compile @ chapter01 <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) @ chapter01 ---
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.0.4
.RELEASE/spring-boot-loader-tools-2.0.4.RELEASE.pom
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.0.4.
RELEASE/spring-boot-loader-tools-2.0.4.RELEASE.pom (0 B at 0.0 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.0.4
.RELEASE/spring-boot-loader-tools-2.0.4.RELEASE.jar
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.0.4.
RELEASE/spring-boot-loader-tools-2.0.4.RELEASE.jar (0 B at 0.0 KB/sec)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
2020-03-02 17:59:11.545 INFO 13280 --- [ main] com.burns.ch1.Chapter01App : Starting Chapter01A
pp on DESKTOP-LOQT6LN with PID 13280 (D:\work\ideaProject\springbootvue\chapter01\target\classes started by 35725 in D:\
work\ideaProject\springbootvue\chapter01)
2020-03-02 17:59:11.549 INFO 13280 --- [ main] com.burns.ch1.Chapter01App : No active profile s
et, falling back to default profiles: default
2020-03-02 17:59:11.607 INFO 13280 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.spri
ngframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1f9d938a: startup date [Mon Mar
02 17:59:11 CST 2020]; root of context hierarchy
2020-03-02 17:59:12.899 INFO 13280 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized
with port(s): 8080 (http)
2020-03-02 17:59:12.938 INFO 13280 --- [ main] o.apache.catalina.core.StandardService : Starting service [T
omcat]
2020-03-02 17:59:12.939 INFO 13280 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet En
gine: Apache Tomcat/8.5.32
2020-03-02 17:59:12.953 INFO 13280 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apach
e Tomcat Native library which allows optimal performance in production environments was not found on the java.library.pa
th: [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\b
in;C:\MentorGraphics\CHS2013\jre\bin\client;C:\MentorGraphics\CHS2012\bin;C:\MentorGraphics\CHS2012\jre\bin;C:\MentorGra
phics\CHS2012\jre\bin\client;C:\MentorGraphics\CHS2017\bin;C:\MentorGraphics\CHS2017\jre\bin;C:\MentorGraphics\CHS2017\j
re\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:\MentorGraphic
s\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:\WI
NDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenS
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
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
\bin;C:\programs\apache-cxf-2.3.0\bin;C:\Program Files\nodejs\;C:\Program Files\PowerShell\6\;C:\Users\35725\AppData\Loc
al\Microsoft\WindowsApps;C:\Users\35725\AppData\Local\BypassRuntm;C:\Users\35725\AppData\Local\Programs\Microsoft VS Cod
e\bin;C:\Users\35725\AppData\Roaming\npm;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;;.]
2020-03-02 17:59:13.062 INFO 13280 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring
embedded WebApplicationContext
2020-03-02 17:59:13.063 INFO 13280 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplication
Context: initialization completed in 1456 ms
2020-03-02 17:59:13.143 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherS
ervlet mapped to [/]
2020-03-02 17:59:13.149 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'ch
aracterEncodingFilter' to: [/*]
2020-03-02 17:59:13.151 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hi
ddenHttpMethodFilter' to: [/*]
2020-03-02 17:59:13.152 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'ht
tpPutFormContentFilter' to: [/*]
2020-03-02 17:59:13.157 INFO 13280 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 're
questContextFilter' to: [/*]
2020-03-02 17:59:13.288 INFO 13280 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/*
*/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-03-02 17:59:13.459 INFO 13280 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @Contro
llerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@1f9d938a: st
artup date [Mon Mar 02 17:59:11 CST 2020]; root of context hierarchy
2020-03-02 17:59:13.536 INFO 13280 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello],m
ethods=[GET]}" onto public java.lang.String com.burns.ch1.controller.HelloConstroller.hello()
2020-03-02 17:59:13.540 INFO 13280 --- [ 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.springframew
ork.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2020-03-02 17:59:13.543 INFO 13280 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],p
roduces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.we
b.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletRespo
nse)
2020-03-02 17:59:13.572 INFO 13280 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/w
ebjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-03-02 17:59:13.573 INFO 13280 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/*
*] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-03-02 17:59:13.717 INFO 13280 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans f
or JMX exposure on startup
2020-03-02 17:59:13.783 INFO 13280 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on p
ort(s): 8080 (http) with context path ''
2020-03-02 17:59:13.788 INFO 13280 --- [ main] com.burns.ch1.Chapter01App : Started Chapter01Ap
p in 2.787 seconds (JVM running for 10.964)
2020-03-02 18:00:06.620 INFO 13280 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring
FrameworkServlet 'dispatcherServlet'
2020-03-02 18:00:06.623 INFO 13280 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'd
ispatcherServlet': initialization started
2020-03-02 18:00:06.645 INFO 13280 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'd
ispatcherServlet': initialization completed in 21 ms
3、浏览器访问http://localhost:8080/hello
4、程序终止的时候按Ctrl+C即可
xposed beans on shutdown
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS终止批处理操作吗(Y/N)? Y
D:\work\ideaProject\springbootvue\chapter01>
二、直接运行入口程序的main方法
这个就需要借助IDE工具了,eclipse或IDEA都可以,这里以IDEA为例
1、入口main方法
package com.burns.ch1;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
//@EnableAutoConfiguration
//@ComponentScan
@SpringBootApplication
public class Chapter01App {
public static void main(String[] args){
SpringApplication.run(Chapter01App.class,args);
}
}
2、启动过程:
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
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
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)
2020-03-02 18:13:21.078 INFO 9672 --- [ main] com.burns.ch1.Chapter01App : No active profile set, falling back to default profiles: default
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
2020-03-02 18:13:22.372 INFO 9672 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-03-02 18:13:22.395 INFO 9672 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-02 18:13:22.396 INFO 9672 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.32
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;;.]
2020-03-02 18:13:22.480 INFO 9672 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-02 18:13:22.481 INFO 9672 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1341 ms
2020-03-02 18:13:22.533 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2020-03-02 18:13:22.538 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2020-03-02 18:13:22.538 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2020-03-02 18:13:22.538 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2020-03-02 18:13:22.538 INFO 9672 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
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]
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
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()
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)
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)
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]
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]
2020-03-02 18:13:23.004 INFO 9672 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
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 ''
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中
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
完整的pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.burns</groupId>
<artifactId>chapter01</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
2、运行maven命令进行打包
在target目录下有一个jar文件生成:
3、命令行运行java -jar chapter01-1.0-SNAPSHOT.jar
D:\work\ideaProject\springbootvue\chapter01\target>java -jar chapter01-1.0-SNAPSHOT.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
2020-03-02 18:23:29.356 INFO 11360 --- [ main] com.burns.ch1.Chapter01App : Starting Chapter01App v1.0-SNAPSHOT on DESKTOP-LOQT6LN
with PID 11360 (D:\work\ideaProject\springbootvue\chapter01\target\chapter01-1.0-SNAPSHOT.jar started by 35725 in D:\work\ideaProject\springbootvue\chapte
r01\target)
2020-03-02 18:23:29.361 INFO 11360 --- [ main] com.burns.ch1.Chapter01App : No active profile set, falling back to default profile
s: default
2020-03-02 18:23:29.437 INFO 11360 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.contex
t.AnnotationConfigServletWebServerApplicationContext@7cef4e59: startup date [Mon Mar 02 18:23:29 CST 2020]; root of context hierarchy
2020-03-02 18:23:31.286 INFO 11360 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-03-02 18:23:31.324 INFO 11360 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-03-02 18:23:31.326 INFO 11360 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.32
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
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
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
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
ics\CHS2013\jre\bin\client;C:\MentorGraphics\CHS2012\bin;C:\MentorGraphics\CHS2012\jre\bin;C:\MentorGraphics\CHS2012\jre\bin\client;C:\MentorGraphics\CHS20
17\bin;C:\MentorGraphics\CHS2017\jre\bin;C:\MentorGraphics\CHS2017\jre\bin\client;C:\MentorGraphics\CHS2011\bin;C:\MentorGraphics\CHS2011\jre\bin;C:\Mentor
Graphics\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:\M
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
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
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
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
assRuntm;C:\Users\35725\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\35725\AppData\Roaming\npm;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;;
.]
2020-03-02 18:23:31.465 INFO 11360 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-03-02 18:23:31.466 INFO 11360 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed i
n 2033 ms
2020-03-02 18:23:31.592 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2020-03-02 18:23:31.602 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2020-03-02 18:23:31.609 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2020-03-02 18:23:31.621 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2020-03-02 18:23:31.652 INFO 11360 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
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
[class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-03-02 18:23:32.109 INFO 11360 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boo
t.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7cef4e59: startup date [Mon Mar 02 18:23:29 CST 2020]; root of context hierarchy
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
g.String com.burns.ch1.controller.HelloConstroller.hello()
2020-03-02 18:23:32.250 INFO 11360 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.ht
tp.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(ja
vax.servlet.http.HttpServletRequest)
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
rg.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.Http
ServletRequest,javax.servlet.http.HttpServletResponse)
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
ass org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
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.
springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-03-02 18:23:32.481 INFO 11360 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
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
th ''
2020-03-02 18:23:32.555 INFO 11360 --- [ main] com.burns.ch1.Chapter01App : Started Chapter01App in 3.641 seconds (JVM running for
4.538)