1
Says Guys, I’m trying to create a Restful application with spring boot here in Ubuntu, however, when I run the application "Run as java application", the server goes up but it seems to me that it does not deploy the application, because when I try to access the url gives error 404.
Detail: In windows works.
Single class:
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class DemoApplication {
@RequestMapping("/")
String home() {
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
POM.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
HERE’S THE LOG
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.3.RELEASE)
2017-02-07 21:13:27.814 INFO 3975 --- [ main] com.example.DemoApplication : Starting DemoApplication on meu pc
2017-02-07 21:13:27.817 INFO 3975 --- [ main] com.example.DemoApplication : No active profile set, falling back to default profiles: default
2017-02-07 21:13:27.858 INFO 3975 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@64cd705f: startup date [Tue Feb 07 21:13:27 BRST 2017]; root of context hierarchy
2017-02-07 21:13:28.894 INFO 3975 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-02-07 21:13:28.904 INFO 3975 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-02-07 21:13:28.905 INFO 3975 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.6
2017-02-07 21:13:28.974 INFO 3975 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-02-07 21:13:28.975 INFO 3975 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1119 ms
2017-02-07 21:13:29.011 INFO 3975 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-02-07 21:13:29.226 INFO 3975 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-02-07 21:13:29.256 INFO 3975 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-02-07 21:13:29.262 INFO 3975 --- [ main] com.example.DemoApplication : Started DemoApplication in 1.881 seconds (JVM running for 2.131)
Url’s I tried to access:
localhost:8080
localhost:8080/demo
localhost:8080/demo/Demoapplication
Thank you in advance.
Try to change the port.
– Lucas Kauer
Speak Lucas blza? thanks for the feedback, I changed the door here and the error still persists :(
– Higor Senna
It is strange because it does not signal any kind of error. The log is complete or is only a part?
– Lucas Kauer
Yes, it does not signal anything, this is the complete log :(, and the strange thing is that windows works...
– Higor Senna
Try accessing with your machine’s IP instead of using localhost.
– Lucas Kauer
tried now and unsuccessfully. (, I searched the net and also could not find the solution to this.
– Higor Senna
Let’s go continue this discussion in chat.
– Lucas Kauer
Which browser you are using?
– Lucas Kauer
tested on Chrome and firefox
– Higor Senna