欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Spring Boot右鍵maven build成功但是直接運(yùn)行main方法出錯(cuò)的解決方案

 更新時(shí)間:2019年08月08日 14:26:55   作者:youreyebows  
這篇文章主要介紹了Spring Boot-右鍵maven build成功但是直接運(yùn)行main方法出錯(cuò)的解決方案,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

1、代碼就一個(gè)Controller,從官網(wǎng)復(fù)制過來的,如下

package com.springboot.controller;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller
@EnableAutoConfiguration
public class SampleController {
  
  @RequestMapping("/index")
  @ResponseBody
  String home() {
    return "Hello World";
  }
  public static void main(String[] args) throws Exception {
    SpringApplication.run(SampleController.class, args);
  }
}

2、在項(xiàng)目上右鍵,maven build,輸入 spring-boot:run,過幾秒后控制臺能看見success,也能看見Hello World,但是沒有傳說中的那個(gè)用字符拼拼出來的spring圖案,而且http://localhost:8080/也打不開,于是我機(jī)智的在上面的SampleController類中右鍵->java Application,果真,出錯(cuò)了,還more than 18... 錯(cuò)誤如下:

1 Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener

等等之類的,就是找不到類的error

3、我的解決辦法

之前我的pom.xml:

 <parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>1.5.8.RELEASE</version>
 </parent>

百度、搜狗、谷歌找了2個(gè)小時(shí)的方法,自己手動引入其他dependency等等都不行,但是更改了springboot的版本就好了,更改后如下:

 <parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>1.4.7.RELEASE</version>
 </parent>

4、最后在SampleController類中右鍵->java Application,終于再console中輸出了:

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

2017-11-03 16:17:14.954 INFO 6416 --- [      main] c.s.controller.SampleController     : Starting SampleController on USER-20170626MT with PID 6416 (D:\j2ee_workspace\SpringTest\target\classes started by Administrator in D:\j2ee_workspace\SpringTest)
2017-11-03 16:17:14.956 INFO 6416 --- [      main] c.s.controller.SampleController     : No active profile set, falling back to default profiles: default
2017-11-03 16:17:15.005 INFO 6416 --- [      main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@411f53a0: startup date [Fri Nov 03 16:17:15 CST 2017]; root of context hierarchy
2017-11-03 16:17:16.688 INFO 6416 --- [      main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-11-03 16:17:16.702 INFO 6416 --- [      main] o.apache.catalina.core.StandardService  : Starting service [Tomcat]

打開http://localhost:8080/也能看見我的Hello World

仔細(xì)觀察了最后一句,應(yīng)該還有一些問題。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Spring AOP手動實(shí)現(xiàn)簡單動態(tài)代理的代碼

    Spring AOP手動實(shí)現(xiàn)簡單動態(tài)代理的代碼

    今天小編就為大家分享一篇關(guān)于Spring AOP手動實(shí)現(xiàn)簡單動態(tài)代理的代碼,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-03-03
  • Java 泛型總結(jié)(三):通配符的使用

    Java 泛型總結(jié)(三):通配符的使用

    在泛型的使用中,還有個(gè)重要的東西叫通配符,本文介紹通配符的使用。具有很好的參考價(jià)值。下面跟著小編一起來看下吧
    2017-03-03
  • 基于Java實(shí)現(xiàn)文件和base64字符串轉(zhuǎn)換

    基于Java實(shí)現(xiàn)文件和base64字符串轉(zhuǎn)換

    這篇文章主要介紹了基于Java實(shí)現(xiàn)文件和base64字符串轉(zhuǎn)換,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-01-01
  • 關(guān)于Java利用反射實(shí)現(xiàn)動態(tài)運(yùn)行一行或多行代碼

    關(guān)于Java利用反射實(shí)現(xiàn)動態(tài)運(yùn)行一行或多行代碼

    這篇文章主要介紹了關(guān)于Java利用反射實(shí)現(xiàn)動態(tài)運(yùn)行一行或多行代碼,借鑒了別人的方法和書上的內(nèi)容,最后將題目完成了,和大家一起分享以下解決方法,需要的朋友可以參考下
    2023-04-04
  • java 中createStatement()方法的實(shí)例詳解

    java 中createStatement()方法的實(shí)例詳解

    這篇文章主要介紹了java 中createStatement()方法的實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • Maven 常用插件的詳細(xì)整理

    Maven 常用插件的詳細(xì)整理

    這篇文章主要介紹了Maven 常用插件的詳細(xì)整理的相關(guān)資料,這里整理了maven的常用插件需要的朋友可以看下,需要的朋友可以參考下
    2017-08-08
  • 史上最全的java隨機(jī)數(shù)生成算法分享

    史上最全的java隨機(jī)數(shù)生成算法分享

    這篇文章主要介紹了史上最全的java隨機(jī)數(shù)生成算法,我分享一個(gè)最全的隨機(jī)數(shù)的生成算法,最代碼的找回密碼的隨機(jī)數(shù)就是用的這個(gè)方法
    2014-01-01
  • Java項(xiàng)目中如何引入Hutool工具類并正確使用它

    Java項(xiàng)目中如何引入Hutool工具類并正確使用它

    Hutool是一個(gè)小而全的Java工具類庫,通過靜態(tài)方法封裝,降低相關(guān)API的學(xué)習(xí)成本,提高工作效率,使Java擁有函數(shù)式語言般的優(yōu)雅,這篇文章主要給大家介紹了關(guān)于Java項(xiàng)目中如何引入Hutool工具類并正確使用它的相關(guān)資料,需要的朋友可以參考下
    2024-01-01
  • java實(shí)現(xiàn)OpenGL ES紋理映射的方法

    java實(shí)現(xiàn)OpenGL ES紋理映射的方法

    這篇文章主要介紹了java實(shí)現(xiàn)OpenGL ES紋理映射的方法,以實(shí)例形式較為詳細(xì)的分析了紋理映射的實(shí)現(xiàn)技巧,需要的朋友可以參考下
    2015-06-06
  • Java中快速把map轉(zhuǎn)成json格式的方法

    Java中快速把map轉(zhuǎn)成json格式的方法

    這篇文章主要介紹了Java中快速把map轉(zhuǎn)成json格式的方法,本文使用json-lib.jar中的JSONSerializer.toJSON方法實(shí)現(xiàn)快速把map轉(zhuǎn)換成json,需要的朋友可以參考下
    2015-07-07

最新評論