SpringBoot 启动问题

luo_dream 2017-06-11 11:14:50
用idea,gradle搭了个spring boot demo,结果发现项目一跑起来就结束了,先贴问题



目录结构如下

build.geadle文件如下

group 'com.halo'
version '1.0-SNAPSHOT'

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


apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'BootDemo'
version = '0.1.0'
}


sourceCompatibility = 1.8
targetCompatibility = 1.8
//repositories {
// mavenCentral()
//}

dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-web")
compile("com.fasterxml.jackson.core:jackson-databind")
testCompile("junit:junit")
}

application.java文件

package app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* Created by Halo on 2017/6/11.
*/
@SpringBootApplication
public class Application {
public static void main(String[] args){
SpringApplication.run(Application.class,args);
}
}


indexcontroller.java如下

package controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* Created by Halo on 2017/6/11.
*/
@RestController
@RequestMapping("/index")
public class IndexController {

@RequestMapping("/")
public String index(){
return "hello World!";
}
}


哪位帮帮看看,只有20分了

...全文
247 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
unclezh0730 2017-06-14
  • 打赏
  • 举报
回复
引用 4 楼 luo_dream 的回复:
你说的方法解决了,但是有个问题,我是按照spring-boot官网来配的,怎么会出现问题呢?
官方的包也是加了compile("org.springframework.boot:spring-boot-starter-web")的,之前我做这个例子的时候maven依赖是这个,spring-web好像也加了
灰祥的奇迹 2017-06-13
  • 打赏
  • 举报
回复
导入的包有问题,将 compile("org.springframework:spring-web") 修改为: compile("org.springframework.boot:spring-boot-starter-web") 这个就可以正常启动了
luo_dream 2017-06-13
  • 打赏
  • 举报
回复
引用 3 楼 huixiangdeqiji 的回复:
导入的包有问题,将 compile("org.springframework:spring-web") 修改为: compile("org.springframework.boot:spring-boot-starter-web") 这个就可以正常启动了
确实是按你说的方法弄好了
luo_dream 2017-06-13
  • 打赏
  • 举报
回复
你说的方法解决了,但是有个问题,我是按照spring-boot官网来配的,怎么会出现问题呢?
破小潘 2017-06-12
  • 打赏
  • 举报
回复
controller位置放的有问题,你换个地方试试.之前有遇到过这个问题
  • 打赏
  • 举报
回复
把日志级别调成debug 就能看到报错信息了

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧