踩坑记录-boot启动报错

从spring.io上生成的项目,到本地启动报错。

控制台输出:

"C:\Program Files\Java\jdk1.8.0_131\bin\java" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.2\lib\idea_rt.jar=62862:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_131\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\rt.jar;D:\WorkSapce\IntelliJ IDEA\demo\target\classes;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter\1.5.7.RELEASE\spring-boot-starter-1.5.7.RELEASE.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot\1.5.7.RELEASE\spring-boot-1.5.7.RELEASE.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-context\4.3.11.RELEASE\spring-context-4.3.11.RELEASE.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-aop\4.3.11.RELEASE\spring-aop-4.3.11.RELEASE.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-beans\4.3.11.RELEASE\spring-beans-4.3.11.RELEASE.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-expression\4.3.11.RELEASE\spring-expression-4.3.11.RELEASE.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.7.RELEASE\spring-boot-autoconfigure-1.5.7.RELEASE.jar;C:\Users\Admin\.m2\repository\org\springframework\boot\spring-boot-starter-logging\1.5.7.RELEASE\spring-boot-starter-logging-1.5.7.RELEASE.jar;C:\Users\Admin\.m2\repository\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;C:\Users\Admin\.m2\repository\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;C:\Users\Admin\.m2\repository\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;C:\Users\Admin\.m2\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;C:\Users\Admin\.m2\repository\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;C:\Users\Admin\.m2\repository\org\springframework\spring-core\4.3.11.RELEASE\spring-core-4.3.11.RELEASE.jar;C:\Users\Admin\.m2\repository\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;C:\Users\Admin\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar" com.example.demo.DemoApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.7.RELEASE)

2017-11-16 17:47:25.087  INFO 20460 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication on Sand with PID 20460 (started by Admin in D:\WorkSapce\IntelliJ IDEA\demo)
2017-11-16 17:47:25.089  INFO 20460 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2017-11-16 17:47:25.126  INFO 20460 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@42d8062c: startup date [Thu Nov 16 17:47:25 CST 2017]; root of context hierarchy
2017-11-16 17:47:25.537  INFO 20460 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-11-16 17:47:25.553  INFO 20460 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 0.691 seconds (JVM running for 1.016)
2017-11-16 17:47:25.557  INFO 20460 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@42d8062c: startup date [Thu Nov 16 17:47:25 CST 2017]; root of context hierarchy
2017-11-16 17:47:25.558  INFO 20460 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

反复核查后发现,是生成的pom.xml有问题。

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter</artifactId>
</dependency>

这里的spring-boot-starter 表示 这是Spring Boot的核心启动器,包含了自动配置、日志和YAML ,但他不是一个web项目

正确:

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>

 

最后加个启动器大全(网上资料)

1)spring-boot-starter 
这是Spring Boot的核心启动器,包含了自动配置、日志和YAML。

2)spring-boot-starter-actuator 
帮助监控和管理应用。

3)spring-boot-starter-amqp 
通过spring-rabbit来支持AMQP协议(Advanced Message Queuing Protocol)。

4)spring-boot-starter-aop 
支持面向方面的编程即AOP,包括spring-aop和AspectJ。

5)spring-boot-starter-artemis 
通过Apache Artemis支持JMS的API(Java Message Service API)。

6)spring-boot-starter-batch 
支持Spring Batch,包括HSQLDB数据库。

7)spring-boot-starter-cache 
支持Spring的Cache抽象。

8)spring-boot-starter-cloud-connectors 
支持Spring Cloud Connectors,简化了在像Cloud Foundry或Heroku这样的云平台上连接服务。

9)spring-boot-starter-data-elasticsearch 
支持ElasticSearch搜索和分析引擎,包括spring-data-elasticsearch。

10)spring-boot-starter-data-gemfire 
支持GemFire分布式数据存储,包括spring-data-gemfire。

11)spring-boot-starter-data-jpa 
支持JPA(Java Persistence API),包括spring-data-jpa、spring-orm、Hibernate。

12)spring-boot-starter-data-mongodb 
支持MongoDB数据,包括spring-data-mongodb。

13)spring-boot-starter-data-rest 
通过spring-data-rest-webmvc,支持通过REST暴露Spring Data数据仓库。

14)spring-boot-starter-data-solr 
支持Apache Solr搜索平台,包括spring-data-solr。

15)spring-boot-starter-freemarker 
支持FreeMarker模板引擎。

16)spring-boot-starter-groovy-templates 
支持Groovy模板引擎。

17)spring-boot-starter-hateoas 
通过spring-hateoas支持基于HATEOAS的RESTful Web服务。

18)spring-boot-starter-hornetq 
通过HornetQ支持JMS。

19)spring-boot-starter-integration 
支持通用的spring-integration模块。

20)spring-boot-starter-jdbc 
支持JDBC数据库。

21)spring-boot-starter-jersey 
支持Jersey RESTful Web服务框架。

22)spring-boot-starter-jta-atomikos 
通过Atomikos支持JTA分布式事务处理。

23)spring-boot-starter-jta-bitronix 
通过Bitronix支持JTA分布式事务处理。

24)spring-boot-starter-mail 
支持javax.mail模块。

25)spring-boot-starter-mobile 
支持spring-mobile。

26)spring-boot-starter-mustache 
支持Mustache模板引擎。

27)spring-boot-starter-redis 
支持Redis键值存储数据库,包括spring-redis。

28)spring-boot-starter-security 
支持spring-security。

29)spring-boot-starter-social-facebook 
支持spring-social-facebook

30)spring-boot-starter-social-linkedin 
支持pring-social-linkedin

31)spring-boot-starter-social-twitter 
支持pring-social-twitter

32)spring-boot-starter-test 
支持常规的测试依赖,包括JUnit、Hamcrest、Mockito以及spring-test模块。

33)spring-boot-starter-thymeleaf 
支持Thymeleaf模板引擎,包括与Spring的集成。

34)spring-boot-starter-velocity 
支持Velocity模板引擎。

35)spring-boot-starter-web 
S支持全栈式Web开发,包括Tomcat和spring-webmvc。

36)spring-boot-starter-websocket 
支持WebSocket开发。

37)spring-boot-starter-ws 
支持Spring Web Services。

Spring Boot应用启动器面向生产环境的还有2种,具体如下:

1)spring-boot-starter-actuator 
增加了面向产品上线相关的功能,比如测量和监控。

2)spring-boot-starter-remote-shell 
增加了远程ssh shell的支持。

最后,Spring Boot应用启动器还有一些替换技术的启动器,具体如下:

1)spring-boot-starter-jetty 
引入了Jetty HTTP引擎(用于替换Tomcat)。

2)spring-boot-starter-log4j 
支持Log4J日志框架。

3)spring-boot-starter-logging 
引入了Spring Boot默认的日志框架Logback。

4)spring-boot-starter-tomcat 
引入了Spring Boot默认的HTTP引擎Tomcat。

5)spring-boot-starter-undertow 
引入了Undertow HTTP引擎(用于替换Tomcat)。

出处链接:http://blog.csdn.net/chszs/article/details/50610474

转载于:https://my.oschina.net/zyldsy/blog/1574667

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值