您的位置:首页 > 编程语言 > Java开发

maven将项目达成jar包并运行mvn package,java -jar 项目jar包

2017-10-14 13:11 375 查看
一、使用mvn package命令打包

yaomingyangdeMacBook-Pro:ggauthority yaomingyang$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ggauthority 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ ggauthority ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ ggauthority ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ ggauthority ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/yaomingyang/Documents/IDE/workplace/ggauthority/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ ggauthority ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.20.1:test (default-test) @ ggauthority ---
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ ggauthority ---
[INFO] Building jar: /Users/yaomingyang/Documents/IDE/workplace/ggauthority/target/ggauthority-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.0.BUILD-SNAPSHOT:repackage (default) @ ggauthority ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.908 s
[INFO] Finished at: 2017-10-14T13:11:48+08:00
[INFO] Final Memory: 22M/390M
[INFO] ------------------------------------------------------------------------
二、在target目录中可以查看到ggauthority-0.0.1-SNAPSHOT.jar文件,使用java -jar ggauthority-0.0.1-SNAPSHOT.jar运行项目

yaomingyangdeMacBook-Pro:work yaomingyang$ java -jar ggauthority-0.0.1-SNAPSHOT.jar

.   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
'  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::  (v2.0.0.BUILD-SNAPSHOT)

2017-10-14 13:10:22.383  INFO 596 --- [           main] g.v1.auth.GgauthorityApplication         : Starting GgauthorityApplication v0.0.1-SNAPSHOT on yaomingyangdeMacBook-Pro.local with PID 596 (/Users/yaomingyang/Documents/work/ggauthority-0.0.1-SNAPSHOT.jar started by yaomingyang in /Users/yaomingyang/Documents/work)
2017-10-14 13:10:22.396  INFO 596 --- [           main] g.v1.auth.GgauthorityApplication         : No active profile set, falling back to default profiles: default
2017-10-14 13:10:22.491  INFO 596 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5d3411d: startup date [Sat Oct 14 13:10:22 CST 2017]; root of context hierarchy
2017-10-14 13:10:25.004  INFO 596 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2017-10-14 13:10:25.030  INFO 596 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-10-14 13:10:25.036  INFO 596 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.23
2017-10-14 13:10:25.195  INFO 596 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-10-14 13:10:25.195  INFO 596 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2708 ms
2017-10-14 13:10:25.398  INFO 596 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-10-14 13:10:25.410  INFO 596 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-10-14 13:10:25.411  INFO 596 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-10-14 13:10:25.411  INFO 596 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-10-14 13:10:25.411  INFO 596 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-10-14 13:10:25.883  INFO 596 --- [           main] s.w.s.m.m.a.RequestMa
c50a
ppingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5d3411d: startup date [Sat Oct 14 13:10:22 CST 2017]; root of context hierarchy
2017-10-14 13:10:26.021  INFO 596 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/list]}" onto public java.lang.String ggauthority.v1.auth.controller.UserController.list()
2017-10-14 13:10:26.029  INFO 596 --- [           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)
2017-10-14 13:10:26.030  INFO 596 --- [           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)
2017-10-14 13:10:26.076  INFO 596 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-10-14 13:10:26.076  INFO 596 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-10-14 13:10:26.130  INFO 596 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-10-14 13:10:26.318  INFO 596 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-10-14 13:10:26.423  INFO 596 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http)
2017-10-14 13:10:26.431  INFO 596 --- [           main] g.v1.auth.GgauthorityApplication         : Started GgauthorityApplication in 4.909 seconds (JVM running for 5.417)


三、项目运行成功可以进行正常的访问
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: