zoukankan      html  css  js  c++  java
  • 使用Maven来运行Springboot项目

    1、如果Eclipse安装了Eclipse-STS插件,Eclipse-STS(Spring Source Tool)插件,那么可以直接使用该插件运行Springboot项目,直接右击main方法,找到运行即可,如下所示:

    2、如果Eclipse软件工具中没有安装STS开发插件,也可以通过Maven的方式运行。直接输入spring-boot:run,就可以启动SpringBoot项目了,如下所示:

    在Goals里面输入spring-boot:run,然后勾选Skip Tests即可,然后点击Apply,最后点击Run运行即可:

    使用Maven的maven build来运行,控制台打印日志,如下所示:

      1 [INFO] Scanning for projects...
      2 [INFO] 
      3 [INFO] -----------------------< com.bie:springboot-01 >------------------------
      4 [INFO] Building springboot-01 0.0.1-SNAPSHOT
      5 [INFO] --------------------------------[ jar ]---------------------------------
      6 [INFO] 
      7 [INFO] >>> spring-boot-maven-plugin:2.3.4.RELEASE:run (default-cli) > test-compile @ springboot-01 >>>
      8 [INFO] 
      9 [INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ springboot-01 ---
     10 [INFO] Using 'UTF-8' encoding to copy filtered resources.
     11 [INFO] Copying 1 resource
     12 [INFO] Copying 0 resource
     13 [INFO] 
     14 [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ springboot-01 ---
     15 [INFO] Changes detected - recompiling the module!
     16 [INFO] Compiling 2 source files to E:eclipseeclipseworkspace_springbootspringboot-01	argetclasses
     17 [INFO] 
     18 [INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ springboot-01 ---
     19 [INFO] Not copying test resources
     20 [INFO] 
     21 [INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ springboot-01 ---
     22 [INFO] Not compiling test sources
     23 [INFO] 
     24 [INFO] <<< spring-boot-maven-plugin:2.3.4.RELEASE:run (default-cli) < test-compile @ springboot-01 <<<
     25 [INFO] 
     26 [INFO] 
     27 [INFO] --- spring-boot-maven-plugin:2.3.4.RELEASE:run (default-cli) @ springboot-01 ---
     28 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-buildpack-platform/2.3.4.RELEASE/spring-boot-buildpack-platform-2.3.4.RELEASE.pom
     29 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-buildpack-platform/2.3.4.RELEASE/spring-boot-buildpack-platform-2.3.4.RELEASE.pom (3.1 kB at 4.4 kB/s)
     30 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/net/java/dev/jna/jna-platform/5.5.0/jna-platform-5.5.0.pom
     31 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/net/java/dev/jna/jna-platform/5.5.0/jna-platform-5.5.0.pom (1.8 kB at 14 kB/s)
     32 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/net/java/dev/jna/jna/5.5.0/jna-5.5.0.pom
     33 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/net/java/dev/jna/jna/5.5.0/jna-5.5.0.pom (1.6 kB at 11 kB/s)
     34 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.pom
     35 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.pom (6.6 kB at 31 kB/s)
     36 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpcomponents-client/4.5.12/httpcomponents-client-4.5.12.pom
     37 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpcomponents-client/4.5.12/httpcomponents-client-4.5.12.pom (16 kB at 120 kB/s)
     38 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.pom
     39 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.pom (5.0 kB at 21 kB/s)
     40 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpcomponents-core/4.4.13/httpcomponents-core-4.4.13.pom
     41 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpcomponents-core/4.4.13/httpcomponents-core-4.4.13.pom (13 kB at 52 kB/s)
     42 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.3.4.RELEASE/spring-boot-loader-tools-2.3.4.RELEASE.pom
     43 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.3.4.RELEASE/spring-boot-loader-tools-2.3.4.RELEASE.pom (2.3 kB at 21 kB/s)
     44 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-plugin-api/3.6.3/maven-plugin-api-3.6.3.pom
     45 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-plugin-api/3.6.3/maven-plugin-api-3.6.3.pom (3.0 kB at 13 kB/s)
     46 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven/3.6.3/maven-3.6.3.pom
     47 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven/3.6.3/maven-3.6.3.pom (26 kB at 177 kB/s)
     48 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-model/3.6.3/maven-model-3.6.3.pom
     49 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-model/3.6.3/maven-model-3.6.3.pom (4.1 kB at 17 kB/s)
     50 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.pom
     51 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.pom (5.3 kB at 39 kB/s)
     52 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-artifact/3.6.3/maven-artifact-3.6.3.pom
     53 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-artifact/3.6.3/maven-artifact-3.6.3.pom (2.4 kB at 9.2 kB/s)
     54 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.pom
     55 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.pom (28 kB at 208 kB/s)
     56 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/org.eclipse.sisu.plexus/0.3.4/org.eclipse.sisu.plexus-0.3.4.pom
     57 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/org.eclipse.sisu.plexus/0.3.4/org.eclipse.sisu.plexus-0.3.4.pom (4.2 kB at 20 kB/s)
     58 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/sisu-plexus/0.3.4/sisu-plexus-0.3.4.pom
     59 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/sisu-plexus/0.3.4/sisu-plexus-0.3.4.pom (14 kB at 106 kB/s)
     60 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.4/org.eclipse.sisu.inject-0.3.4.pom
     61 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.4/org.eclipse.sisu.inject-0.3.4.pom (2.6 kB at 11 kB/s)
     62 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/sisu-inject/0.3.4/sisu-inject-0.3.4.pom
     63 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/sisu-inject/0.3.4/sisu-inject-0.3.4.pom (14 kB at 124 kB/s)
     64 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-classworlds/2.6.0/plexus-classworlds-2.6.0.pom
     65 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-classworlds/2.6.0/plexus-classworlds-2.6.0.pom (7.9 kB at 34 kB/s)
     66 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-buildpack-platform/2.3.4.RELEASE/spring-boot-buildpack-platform-2.3.4.RELEASE.jar
     67 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar
     68 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.jar
     69 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/net/java/dev/jna/jna/5.5.0/jna-5.5.0.jar
     70 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/net/java/dev/jna/jna-platform/5.5.0/jna-platform-5.5.0.jar
     71 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-buildpack-platform/2.3.4.RELEASE/spring-boot-buildpack-platform-2.3.4.RELEASE.jar (183 kB at 731 kB/s)
     72 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.3.4.RELEASE/spring-boot-loader-tools-2.3.4.RELEASE.jar
     73 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar (329 kB at 538 kB/s)
     74 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-plugin-api/3.6.3/maven-plugin-api-3.6.3.jar
     75 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/maven/maven-plugin-api/3.6.3/maven-plugin-api-3.6.3.jar (47 kB at 49 kB/s)
     76 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/org.eclipse.sisu.plexus/0.3.4/org.eclipse.sisu.plexus-0.3.4.jar
     77 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/springframework/boot/spring-boot-loader-tools/2.3.4.RELEASE/spring-boot-loader-tools-2.3.4.RELEASE.jar (242 kB at 161 kB/s)
     78 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
     79 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar (45 kB at 25 kB/s)
     80 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.4/org.eclipse.sisu.inject-0.3.4.jar
     81 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/org.eclipse.sisu.plexus/0.3.4/org.eclipse.sisu.plexus-0.3.4.jar (205 kB at 114 kB/s)
     82 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
     83 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.jar (778 kB at 282 kB/s)
     84 [INFO] Downloading from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-classworlds/2.6.0/plexus-classworlds-2.6.0.jar
     85 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar (262 kB at 90 kB/s)
     86 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.4/org.eclipse.sisu.inject-0.3.4.jar (379 kB at 121 kB/s)
     87 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/org/codehaus/plexus/plexus-classworlds/2.6.0/plexus-classworlds-2.6.0.jar (53 kB at 17 kB/s)
     88 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/net/java/dev/jna/jna/5.5.0/jna-5.5.0.jar (1.5 MB at 401 kB/s)
     89 [INFO] Downloaded from nexus-aliyun: http://maven.aliyun.com/nexus/content/groups/public/net/java/dev/jna/jna-platform/5.5.0/jna-platform-5.5.0.jar (2.7 MB at 586 kB/s)
     90 [INFO] Attaching agents: []
     91 
     92   .   ____          _            __ _ _
     93  /\ / ___'_ __ _ _(_)_ __  __ _    
     94 ( ( )\___ | '_ | '_| | '_ / _` |    
     95  \/  ___)| |_)| | | | | || (_| |  ) ) ) )
     96   '  |____| .__|_| |_|_| |_\__, | / / / /
     97  =========|_|==============|___/=/_/_/_/
     98  :: Spring Boot ::        (v2.3.4.RELEASE)
     99 
    100 2020-10-24 11:53:18.219  INFO 10196 --- [           main] com.bie.Springboot01Application          : Starting Springboot01Application on DESKTOP-V37QSSE with PID 10196 (E:eclipseeclipseworkspace_springbootspringboot-01	argetclasses started by biehl in E:eclipseeclipseworkspace_springbootspringboot-01)
    101 2020-10-24 11:53:18.221  INFO 10196 --- [           main] com.bie.Springboot01Application          : No active profile set, falling back to default profiles: default
    102 2020-10-24 11:53:19.608  INFO 10196 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
    103 2020-10-24 11:53:19.617  INFO 10196 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    104 2020-10-24 11:53:19.617  INFO 10196 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.38]
    105 2020-10-24 11:53:19.666  INFO 10196 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    106 2020-10-24 11:53:19.667  INFO 10196 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1412 ms
    107 2020-10-24 11:53:19.782  INFO 10196 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
    108 2020-10-24 11:53:19.898  INFO 10196 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
    109 2020-10-24 11:53:19.907  INFO 10196 --- [           main] com.bie.Springboot01Application          : Started Springboot01Application in 1.968 seconds (JVM running for 2.275)

    注意:当使用Eclipse-STS建立了SpringBoot项目时,会在项目后面标记 [boot] 的提示信息。

    SpringBoot自带Tomcat容器,所以项目启动后通过浏览器输入http://localhost:8080,就可以直接访问控制器返回的信息。最后加上自己的控制层请求路径即可访问到方法返回信息。

  • 相关阅读:
    ubuntu server 12.04中文显示不了
    hustoj升级
    oj资源
    考试系统
    怎样用DOS命令替换文本里的某段字符
    ubuntu一键安装lamp
    Windows Server 2008官方简体中文正式版下载+序列号
    vsphere ubuntu网速很慢
    前端
    (运维)VMwarevCenterServerAppliance5.0安装与部署
  • 原文地址:https://www.cnblogs.com/biehongli/p/13868287.html
Copyright © 2011-2022 走看看