无法访问springboot应用

时间:2017-03-15 21:10:08

标签: java spring spring-boot

我创建了一个SpringBoot应用程序。当我启动应用程序时,我收到一条消息,说明 Tomcat在端口上启动:8080(http)

但是当我尝试通过在浏览器中提供localhost:8080来访问服务器时,我看到了 - "找不到这个本地主页页面"

主要类

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan({"com.cloud.validator"})
public class Validator{

    public static void main(String[] args) {
        SpringApplication.run(Validator.class, args);
    }

}

控制器类

@RestController
public class TransactionController {

    @Autowired
    private TransactionComparator comparator;

    @RequestMapping(value ="transactions", method = RequestMethod.POST , produces=MediaType.APPLICATION_JSON_VALUE)
    public List<TransactionDetails> transactions(TransactionRequest request){
        return comparator.validateTransaction(request);
    }


}

应用程序属性

server.contextPath=/txnscomparator

Build.gradle依赖

dependencies {
    compile('org.springframework.boot:spring-boot-starter-jdbc')
    compile("org.springframework.boot:spring-boot-starter-web")
    compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3.3'
    compile group: 'joda-time', name: 'joda-time', version: '2.8.1'
    compile(group: 'com.oracle', name: 'ojdbc6', version: '12.1.0.1')
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

0 个答案:

没有答案