Невозможно открыть приложение Simple springboot на http://localhost:8088/hello - PullRequest
0 голосов
/ 11 марта 2019

Я новичок в Java и Springboot. Все, что я пытался сделать, это запустить простое приложение Springboot.

Среда: выпуск сообщества Intellji

Я все перепробовал. file-invalidatecahes / restart, указать базовый пакет контроллера. но ничего не работает

Ошибка при попытке открыть localhost в браузере:

[This localhost page can’t be found
No webpage was found for the web address: http://localhost:8088/hello
Search Google for localhost 8088 hello
HTTP ERROR 404][1]

мой контроллер:

package com.example.demo1.Controller;


import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class DemoController {
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String ram(){
        return "success the app is working";
    }

}

мой основной метод:

package com.example.demo1;

import com.example.demo1.Controller.DemoController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;


@SpringBootApplication
@ComponentScan(basePackageClasses = DemoController.class)
public class Demo1Application {

    public static void main(String[] args) {
        System.out.println("hi iam here 123");
        SpringApplication.run(Demo1Application.class, args);
    }

}

Выполнение журнала / трассировки стека:

hi iam here 123

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

2019-03-11 10:06:04.724  INFO 10852 --- [           main] com.example.demo1.Demo1Application       : Starting Demo1Application on H18LAFI12PS0092 with PID 10852 (C:\demo1\demo1\target\classes started by rm91243 in C:\demo1)
2019-03-11 10:06:05.055  INFO 10852 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@12679d6: startup date [Mon Mar 11 10:06:05 CDT 2019]; root of context hierarchy
2019-03-11 10:06:07.305  INFO 10852 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2019-03-11 10:06:08.824  INFO 10852 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8088 (http)
2019-03-11 10:06:09.158  INFO 10852 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2019-03-11 10:06:09.160  INFO 10852 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.28
2019-03-11 10:06:09.511  INFO 10852 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/demo]   : Initializing Spring embedded WebApplicationContext
2019-03-11 10:06:09.512  INFO 10852 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4462 ms
2019-03-11 10:06:11.299  INFO 10852 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2019-03-11 10:06:11.304  INFO 10852 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-11 10:06:11.305  INFO 10852 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-11 10:06:11.719  INFO 10852 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@12679d6: startup date [Mon Mar 11 10:06:05 CDT 2019]; root of context hierarchy
2019-03-11 10:06:11.812  INFO 10852 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello],methods=[GET]}" onto public java.lang.String com.example.demo1.Controller.DemoController.ram()
2019-03-11 10:06:11.814  INFO 10852 --- [           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.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-11 10:06:11.815  INFO 10852 --- [           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.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2019-03-11 10:06:11.854  INFO 10852 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 10:06:11.855  INFO 10852 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 10:06:11.905  INFO 10852 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-11 10:06:12.055  INFO 10852 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-03-11 10:06:12.224  INFO 10852 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8088 (http)
2019-03-11 10:06:12.227  INFO 10852 --- [           main] com.example.demo1.Demo1Application       : Started Demo1Application in 8.593 seconds (JVM running for 9.936)

Запрос вашей помощи. Спасибо

...