I am new to spring boot, create a basic example with no connection to BD, I only have the dependency spring-boot-starter-web and spring-boot-starter
My main class:
package com.sinbugs.contacts;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@EnableAutoConfiguration
@RestController
public class EasyNotes1Application {
@RequestMapping("/")
String home() {
return "Hola por fa";
}
public static void main(String[] args) {
SpringApplication.run(EasyNotes1Application.class, args);
}
}
POM:
<?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.sinbugs</groupId>
<artifactId>contact-ws</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>easy-notes1</name>
<description>Servicio web REST simple</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.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>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When I run the application (Exit the console):
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _' | \ \ \ \
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.2.RELEASE)
2018-05-31 09:19:14.120 INFO 4052 --- [ main] c.s.contacts.EasyNotes1Application : Starting EasyNotes1Application on tony with PID 4052 (C:\Users\antony\Documents\workspace-sts-3.9.1.RELEASE\easy-notes1\target\classes started by antony in C:\Users\antony\Documents\workspace-sts-3.9.1.RELEASE\easy-notes1)
2018-05-31 09:19:14.124 INFO 4052 --- [ main] c.s.contacts.EasyNotes1Application : No active profile set, falling back to default profiles: default
2018-05-31 09:19:14.199 INFO 4052 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@5d47c63f: startup date [Thu May 31 09:19:14 COT 2018]; root of context hierarchy
2018-05-31 09:19:16.118 INFO 4052 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-05-31 09:19:16.146 INFO 4052 --- [ main] c.s.contacts.EasyNotes1Application : Started EasyNotes1Application in 2.852 seconds (JVM running for 4.202)
2018-05-31 09:19:16.149 INFO 4052 --- [ Thread-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@5d47c63f: startup date [Thu May 31 09:19:14 COT 2018]; root of context hierarchy
2018-05-31 09:19:16.151 INFO 4052 --- [ Thread-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
But I joined the URL: localhost: 8080 and I refused the connection.