Intellij Springboot启动时出现问题

斯特凡诺·米塞利(Stefano Miceli)

我对Spring Boot真的很陌生,因此我从一些教程开始,以创建一个简单的Rest示例(我的最终目标是将其与mongodb集成,但是我需要开始!)。我使用Spring Initializr在IntelliJ上创建了一个新项目,并选择了Web和Mongodb作为功能。然后我只添加了一个类,

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

@RestController
public class HelloController {

@RequestMapping("/")
public String index() {
    return "Greetings from Spring Boot!";
}

}

当我运行项目时,控制台是

 2018-09-03 20:08:33.139  INFO 1363 --- [           main] 
 test.test.TestApplication                : Starting TestApplication on 
 MacBook-Pro-di-Stefano.local with PID 1363 
 (/Users/stefanomiceli/IdeaProjects/test/target/classes started by 
 stefanomiceli in /Users/stefanomiceli/IdeaProjects/test)
 2018-09-03 20:08:33.141  INFO 1363 --- [           main] 
 test.test.TestApplication                : No active profile set, 
 falling back to default profiles: default
 2018-09-03 20:08:33.173  INFO 1363 --- [           main] 
 ConfigServletWebServerApplicationContext : Refreshing 

org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@15713d56: startup date [Mon Sep 03 20:08:33 PDT 2018]; root of context hierarchy

 WARNING: An illegal reflective access operation has occurred
 WARNING: Illegal reflective access by 
 org.springframework.cglib.core.ReflectUtils$1 
 (file:/Users/stefanomiceli/.m2/repository/org/springframework/spring- 
 core/5.0.8.RELEASE/spring-core-5.0.8.RELEASE.jar) to method 


java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)

 WARNING: Please consider reporting this to the maintainers of 
 org.springframework.cglib.core.ReflectUtils$1
 WARNING: Use --illegal-access=warn to enable warnings of further 
 illegal reflective access operations
 WARNING: All illegal access operations will be denied in a future 
 release
 2018-09-03 20:08:33.950  INFO 1363 --- [           main] 
 o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with 
 port(s): 8080 (http)
 2018-09-03 20:08:33.969  INFO 1363 --- [           main] 
 o.apache.catalina.core.StandardService   : Starting service [Tomcat]
 2018-09-03 20:08:33.969  INFO 1363 --- [           main] 
 org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: 
 Apache Tomcat/8.5.32
 2018-09-03 20:08:33.972  INFO 1363 --- [ost-startStop-1] 
 o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat 
 Native library which allows optimal performance in production 
 environments was not found on the java.library.path: 


 [/Users/stefanomiceli/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]

 2018-09-03 20:08:34.021  INFO 1363 --- [ost-startStop-1] o.a.c.c.C. 
 [Tomcat].[localhost].[/]       : Initializing Spring embedded 
 WebApplicationContext
 2018-09-03 20:08:34.021  INFO 1363 --- [ost-startStop-1] 
 o.s.web.context.ContextLoader            : Root WebApplicationContext: 
 initialization completed in 852 ms
 2018-09-03 20:08:34.059  INFO 1363 --- [ost-startStop-1] 
 o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet 
 mapped to [/]
 2018-09-03 20:08:34.061  INFO 1363 --- [ost-startStop-1] 
 o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 
 'characterEncodingFilter' to: [/*]
 2018-09-03 20:08:34.062  INFO 1363 --- [ost-startStop-1] 
 o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 
 'hiddenHttpMethodFilter' to: [/*]
 2018-09-03 20:08:34.062  INFO 1363 --- [ost-startStop-1] 
 o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 
 'httpPutFormContentFilter' to: [/*]
 2018-09-03 20:08:34.062  INFO 1363 --- [ost-startStop-1] 
 o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 
 'requestContextFilter' to: [/*]
 2018-09-03 20:08:34.143  INFO 1363 --- [           main] 
 o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path 
 [/**/favicon.ico] onto handler of type [class 
 org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
 2018-09-03 20:08:34.310  INFO 1363 --- [           main] 
 s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for 
 @ControllerAdvice: 



org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@15713d56: startup date [Mon Sep 03 20:08:33 PDT 2018]; root of context hierarchy

 2018-09-03 20:08:34.344  INFO 1363 --- [           main] 
 s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto 
 public 
    org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> 
  org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)

 2018-09-03 20:08:34.345  INFO 1363 --- [           main] 
 s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=      [text/html]}" onto public org.springframework.web.servlet.ModelAndView 


org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)

 2018-09-03 20:08:34.362  INFO 1363 --- [           main] 
 o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path 
 [/webjars/**] onto handler of type [class 
 org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
 2018-09-03 20:08:34.362  INFO 1363 --- [           main] 
 o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto 
 handler of type [class 
 org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
 2018-09-03 20:08:34.550  INFO 1363 --- [           main] 
 org.mongodb.driver.cluster               : Cluster created with 
 settings {hosts=[localhost:27017], mode=SINGLE, 
 requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', 
 maxWaitQueueSize=500}
 2018-09-03 20:08:34.582  INFO 1363 --- [localhost:27017] 
 org.mongodb.driver.connection            : Opened connection 
 [connectionId{localValue:1, serverValue:55}] to localhost:27017
 2018-09-03 20:08:34.585  INFO 1363 --- [localhost:27017] 
 org.mongodb.driver.cluster               : Monitor thread successfully 
 connected to server with description 
 ServerDescription{address=localhost:27017, type=STANDALONE, 
 state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 
 1]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, 
 logicalSessionTimeoutMinutes=30, roundTripTimeNanos=1582641}
 2018-09-03 20:08:34.739  INFO 1363 --- [           main] 
 o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX 
 exposure on startup
 2018-09-03 20:08:34.768  INFO 1363 --- [           main] 
 o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 
 8080 (http) with context path ''
 2018-09-03 20:08:34.772  INFO 1363 --- [           main] 
 test.test.TestApplication                : Started TestApplication in 
 1.834 seconds (JVM running for 7.413)

但是当我继续时,localhost:8080/我会404出错。我在helloworld中做错了什么?在运行该应用程序之前,我应该做些什么吗?

西蒙·马丁内利

您的包裹结构错误:

prova.HelloController

test.test.TestApplication

HelloController必须处于同一级别或低于TestApplication。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

蜂巢-启动时出现问题

在Intellij IDEA中打开Gradle项目时出现问题

在 IntelliJ 中导入 CSVParser 时出现问题

从Intellij IDE部署Java AWS Lambda时出现问题

从3.0 USB启动时出现问题

尝试对预加载器使用LauncherImpl时JavaFX / Intellij设置出现问题

在IntelliJ Idea中编译和运行Scala项目时出现问题

.wav在从Intellij IDEA创建的jar文件中播放时出现问题

在Windows启动时启动启动文件夹中的程序时出现问题

在计算机启动时启动JBoss 7.02服务器时出现问题

IntelliJ IDEA“自动创建项目”出现问题

IntelliJ IDEA启动时如何防止最后打开的项目?

启动时,通过 vbs 脚本运行 bat 文件时出现问题

已设置应用程序以记住其设置,但是首次启动时出现问题

戴尔 G3 在使用 Ubuntu 启动时出现问题

设置Lenovo IdeaCentre K450 USB启动时出现问题

Nodejs 应用程序在本地运行良好,但在线启动时出现问题

Debian启动时出现问题“等待设备dev-disk超时...”

设置systemd服务以在重新启动时运行屏幕时出现问题

运行IntelliJ测试时出现IntelliJ NoClassDefFoundError

启动Sikuli设置时出现问题

IntelliJ/Android 工作室在启动时挂起。如何禁用导致 Intelleij/Android Studio 在启动时挂起的插件?

使用uvicorn.run以编程方式启动时,启用Uvicorn自动重启时出现问题

Intellij IDEA在启动时启动另一个图标

运行Java构件时显示Unicode字符时出现问题,但在IntelliJ IDEA中运行时一切正常

我的应用在第二个活动中启动时出现问题

使用IntelliJ启动时,Spring Boot不提供资源文件夹中的资产

Intellij VCS在应用程序启动时自动更新

当IntelliJ启动时,我总是会重新导入我的Maven依赖项