点击上方 Java老铁,并选择 设为星标
优质文章和资料会及时送达
在你的idea中创建好SpringBoot项目,然后按照如下操作:
1.在pom文件添加如下:
<build>
<plugins>
<plugin>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-maven-plugin </artifactId>
</plugin>
</plugins>
</build>
2.输入命令 mvn package
F:\workspaceIdeaSrc\springBoot-vue>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< org.example:springBoot-vue >---------------------
[INFO] Building springBoot-vue 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ springBoot-vue ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ springBoot-vue ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory F:\workspaceIdeaSrc\springBoot-vue\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ springBoot-vue ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ springBoot-vue ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ springBoot-vue ---
[INFO] Building jar: F:\workspaceIdeaSrc\springBoot-vue\target\springBoot-vue-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.1.RELEASE:repackage (default) @ springBoot-vue ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.704 s
[INFO] Finished at: 2020-09-24T17:18:41+08:00
[INFO] ------------------------------------------------------------------------
这时我们就会发现在target目录下多了一个springBoot-vue-1.0-SNAPSHOT.jar
3.输入命令 java -jar target/springBoot-vue-1.0-SNAPSHOT.jar
F:\workspaceIdeaSrc\springBoot-vue>java -jar target/springBoot-vue-1.0-SNAPSHOT.jar
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.1.RELEASE)
2020-09-24 17:21:55.889 INFO 18648 --- [ main] com.eu.demo.Application : Starting Application v1.0-SNAPSHOT on DESKTOP-2T6MQTD with PID
18648 (F:\workspaceIdeaSrc\springBoot-vue\target\springBoot-vue-1.0-SNAPSHOT.jar started by admin in F:\workspaceIdeaSrc\springBoot-vue)
2020-09-24 17:21:55.911 INFO 18648 --- [ main] com.eu.demo.Application : No active profile set, falling back to default profiles: defau
lt
2020-09-24 17:21:56.122 INFO 18648 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.Annota
tionConfigServletWebServerApplicationContext@2471cca7: startup date [Thu Sep 24 17:21:56 CST 2020]; root of context hierarchy
2020-09-24 17:22:02.289 INFO 18648 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8001 (http)
2020-09-24 17:22:02.341 INFO 18648 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-09-24 17:22:02.341 INFO 18648 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.29
2020-09-24 17:22:02.363 INFO 18648 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optima
l performance in production environments was not found on the java.library.path: [F:\Java\jdk1.8.0_171\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;F
:\soft\NetSarang\Xftp6\;F:\soft\NetSarang\Xshell6\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;F:\Java\jdk1
.8.0_171\bin;F:\Java\jdk1.8.0_171\jre\bin;F:\teache\MySQL\MySQL Server 5.5\bin;C:\WINDOWS\System32\OpenSSH\;F:\teache\Graphviz2.38\bin;F:\soft\NetSarang\Xftp 6\;F:
\teache\MongoDB\Server\3.2\bin;F:\teache\nodejs\;F:\teache\apache-maven-3.5.4\bin\;F:\soft\HashiCorp\Vagrant\bin;F:\teache\gradle\gradle-5.1\bin;F:\teache\Tortoise
Git\bin;F:\teache\MongoDB\bin;F:\teache\erl9.2\bin;F:\teache\Python\Python38\Scripts\;F:\teache\Python\Python38\;C:\Users\admin\AppData\Local\Microsoft\WindowsApp
s;F:\teache\Microsoft VS Code\bin;F:\teache\IntelliJ IDEA 193.4697.15\bin;F:\teache\PyCharm 2019.2.4\bin;C:\Users\admin\AppData\Roaming\npm;C:\Users\admin\AppDat
a\Local\GitHubDesktop\bin;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;;F:\teache\CLion 2020.1.3\bin;;.]
2020-09-24 17:22:02.581 INFO 18648 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-09-24 17:22:02.583 INFO 18648 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6465 m
s
2020-09-24 17:22:03.163 INFO 18648 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2020-09-24 17:22:03.166 INFO 18648 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet statViewServlet mapped to [/druid/*]
2020-09-24 17:22:03.171 INFO 18648 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2020-09-24 17:22:03.172 INFO 18648 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2020-09-24 17:22:03.172 INFO 18648 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2020-09-24 17:22:03.173 INFO 18648 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2020-09-24 17:22:03.173 INFO 18648 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webStatFilter' to urls: [/*]
2020-09-24 17:22:03.174 INFO 18648 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'corsFilter' to: [/*]
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
2020-09-24 17:22:03.642 INFO 18648 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2020-09-24 17:22:04.516 INFO 18648 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
Parsed mapper file: 'class path resource [mapper/StudentMapper.xml]'
Parsed mapper file: 'class path resource [mapper/UserMapper.xml]'
2020-09-24 17:22:05.079 INFO 18648 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class
org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-09-24 17:22:05.482 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.se
rvlet.context.AnnotationConfigServletWebServerApplicationContext@2471cca7: startup date [Thu Sep 24 17:21:56 CST 2020]; root of context hierarchy
2020-09-24 17:22:05.643 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello],methods=[GET]}" onto public java.lang.String
com.eu.demo.controller.HelloController.hello()
2020-09-24 17:22:05.653 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getStudents],methods=[GET]}" onto public com.eu.dem
o.common.Result com.eu.demo.controller.StudentController.getStudnets()
2020-09-24 17:22:05.654 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/getStudentsById/{id}],methods=[GET]}" onto public c
om.eu.demo.common.Result com.eu.demo.controller.StudentController.getStudentsById(java.lang.Integer)
2020-09-24 17:22:05.656 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/update/{id}],methods=[PUT]}" onto public com.eu.dem
o.common.Result com.eu.demo.controller.StudentController.updateStudent(java.lang.Integer,com.eu.demo.pojo.Student)
2020-09-24 17:22:05.662 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/delete],methods=[DELETE]}" onto public com.eu.demo.
common.Result com.eu.demo.controller.StudentController.deleteStudentById(java.lang.Integer)
2020-09-24 17:22:05.670 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/login],methods=[GET]}" onto public com.eu.demo.comm
on.Result com.eu.demo.controller.UserController.login(java.lang.String,java.lang.String)
2020-09-24 17:22:05.675 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.Respo
nseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http
.HttpServletRequest)
2020-09-24 17:22:05.678 INFO 18648 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.sprin
gframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,j
avax.servlet.http.HttpServletResponse)
2020-09-24 17:22:05.776 INFO 18648 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.
springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-09-24 17:22:05.777 INFO 18648 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springfr
amework.web.servlet.resource.ResourceHttpRequestHandler]
2020-09-24 17:22:06.332 INFO 18648 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2020-09-24 17:22:06.341 INFO 18648 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'statFilter' has been autodetected for JMX expo
sure
2020-09-24 17:22:06.342 INFO 18648 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX expo
sure
2020-09-24 17:22:06.353 INFO 18648 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBe
an [com.alibaba.druid.spring.boot.autoconfigure:name=dataSource,type=DruidDataSourceWrapper]
2020-09-24 17:22:06.356 INFO 18648 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'statFilter': registering with JMX server as MBe
an [com.alibaba.druid.filter.stat:name=statFilter,type=StatFilter]
2020-09-24 17:22:06.448 INFO 18648 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8001 (http) with context path ''
2020-09-24 17:22:06.461 INFO 18648 --- [ main] com.eu.demo.Application : Started Application in 11.632 seconds (JVM running for 12.722)
2020-09-24 17:22:42.643 INFO 18648 --- [nio-8001-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2020-09-24 17:22:42.644 INFO 18648 --- [nio-8001-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2020-09-24 17:22:42.776 INFO 18648 --- [nio-8001-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed
in 132 ms
这样springBoot项目就被启动了,可以直接在浏览器输入地址运行。
关注我
获取更多
Java干货
原创文章
视频资料
技术交流群