解决springboot项目无法正常启动的问题

2 篇文章 0 订阅
1 篇文章 0 订阅

最近在搭建一个springboot(springboot版本是1.5.1.RELEASE)的web项目时(编译类型是gradle),总是无法正常启动,网上各种找解决办法,都没能解决问题。下面简单给出build.gradle的配置。

先给出错误提示信息:

2019-10-21 17:55:13.636  INFO 7180 --- [           main] c.h.l.s.demo.SpringBootDemoApplication   : Started SpringBootDemoApplication in 10.394 seconds (JVM running for 10.922)
2019-10-21 17:55:13.639  INFO 7180 --- [       Thread-5] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4386f16: startup date [Mon Oct 21 17:55:03 CST 2019]; root of context hierarchy
2019-10-21 17:55:13.643  INFO 7180 --- [       Thread-5] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

项目的build.gradle配置如下:


buildscript{
   ext{
     sprintBootVersion = '1.5.1.RELEASE'
   }
   repositories{
     maven {url "http://maven.aliyun.com/nexus/content/groups/public/"}
   }
   dependencies{
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${sprintBootVersion}")
   }   
}

apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

mainClassName = 'com.xxx.xxx.demo.SpringBootDemoApplication'

group = 'com.hezs.learn.springboot'
version = '0.0.1-SNAPSHOT'

jar{
   baseName = 'springbootdemo'
   version = '1.0.0'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8



repositories { 
  maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
} 

dependencies {
    runtime "mysql:mysql-connector-java:6.0.3"
	compile "org.flywaydb:flyway-core:3.2.1"
	compile 'org.projectlombok:lombok:1.16.12'
	compile "org.springframework.boot:spring-boot-starter-parent:${sprintBootVersion}"
	compile "org.springframework.boot:spring-boot-starter-web:${sprintBootVersion}"
	compile "org.springframework.boot:spring-boot-starter-data-jpa:${sprintBootVersion}"
	compile "org.springframework.boot:spring-boot-starter-tomcat:${sprintBootVersion}"
	testCompile "org.springframework.boot:spring-boot-starter-test:${sprintBootVersion}"
}

网上给出了各种解决办法,都试过之后,无解
最后找到一个提示性的答案,Tomcat的依赖方式,在maven的pom.xml中是provided,对应的gradle是compileOnly,仅仅需要修改一下依赖方法就OK了
compile "org.springframework.boot:spring-boot-starter-tomcat:${sprintBootVersion}"
–>
compileOnly "org.springframework.boot:spring-boot-starter-tomcat:${sprintBootVersion}"
问题得到解决。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

banche168

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值