Springboot executable jar can not access index page - java

I created an application with springboot, restapi and angularjs. I will turn this project as executable jar. but when i do java -jar patchinit.jar, it does not reload index page. it gives
Whitelabel Error Page (There was an unexpected error (type=Not Found,
status=404 No message available)
Trying to http://localhost:8080/
Am i missing something? I almost tried everything desperately..
POM.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ama.ist</groupId>
<artifactId>patchinit</artifactId>
<packaging>jar</packaging>
<version>0.0.1</version>
<name>patchinit Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<properties>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</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.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.7.8</version>
</dependency>
</dependencies>
<build>
<finalName>patchinit</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Webapplication.java
package com.ama.ist;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.RequestMapping;
#SpringBootApplication
public class WebApplication extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(WebApplication.class, args);
}
}
HelloController.java
package com.ama.ist.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
#Controller
public class HelloController {
#RequestMapping("/")
String index() {
return "index";
}
}
index.html
<!DOCTYPE html>
<html ng-app="MyApp">
<head>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.5/angular-material.min.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4 jumbotron">
<div class="col-md-12 dialog-demo-content">
<div ui-view="newPatch"></div>
</div>
</div>
<div class="col-md-8 ">
<div ui-view="svntab"></div>
</div>
</div>
</div>
<!-- <div class="container" class="md-padding" ng-cloak> -->
<!-- <div class="row"> -->
<!-- <div class="col-md-3 dialog-demo-content"> -->
<!-- <div ui-view="newPatch"></div> -->
<!-- </div> -->
<!-- <div class="col-md-2"></div> -->
<!-- <div class="col-md-3"> -->
<!-- <div ui-view="svntab"></div> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<!-- ************************* SCRIPTS ********************************** -->
<script src="https://code.angularjs.org/1.5.8/angular.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.8/angular-ui-router.min.js"></script>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
<script
src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>
<script src="js/app.js"></script>
<script src="js/patch.controller.js"></script>
<script src="js/svn.controller.js"></script>
</body>
</html>
This is the output of springboot
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.5.RELEASE)
2017-12-05 19:54:09.019 INFO 480 --- [ main] com.ama.ist.WebApplication : Starting WebApplication on ISTL55310 with PID 480 (C:\Erkan\eclipse-workspace-new\patchinit\target\classes started by erkan.erkisi in C:\Erkan\eclipse-workspace-new\patchinit)
2017-12-05 19:54:09.022 INFO 480 --- [ main] com.ama.ist.WebApplication : No active profile set, falling back to default profiles: default
2017-12-05 19:54:09.063 INFO 480 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1ce2a846: startup date [Tue Dec 05 19:54:09 EET 2017]; root of context hierarchy
2017-12-05 19:54:10.335 INFO 480 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-12-05 19:54:10.345 INFO 480 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-12-05 19:54:10.347 INFO 480 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.33
2017-12-05 19:54:10.987 INFO 480 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2017-12-05 19:54:10.994 INFO 480 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-12-05 19:54:10.994 INFO 480 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1933 ms
2017-12-05 19:54:11.468 INFO 480 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-12-05 19:54:11.471 INFO 480 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-12-05 19:54:11.471 INFO 480 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-12-05 19:54:11.471 INFO 480 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-12-05 19:54:11.471 INFO 480 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-12-05 19:54:11.639 INFO 480 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1ce2a846: startup date [Tue Dec 05 19:54:09 EET 2017]; root of context hierarchy
2017-12-05 19:54:11.697 INFO 480 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto java.lang.String com.ama.ist.controller.HelloController.index()
2017-12-05 19:54:11.698 INFO 480 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/resource]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.ama.ist.controller.PatchController.home()
2017-12-05 19:54:11.698 INFO 480 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/mk],methods=[POST]}" onto public org.springframework.http.ResponseEntity<?> com.ama.ist.controller.PatchController.createFolder(com.ama.ist.model.Patch)
2017-12-05 19:54:11.701 INFO 480 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/localfolders],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.ama.ist.model.Folder>> com.ama.ist.controller.SvnController.getlocalFolders(com.ama.ist.model.User)
2017-12-05 19:54:11.702 INFO 480 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/svnfolders],methods=[GET]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.ama.ist.model.Folder>> com.ama.ist.controller.SvnController.getFolders(com.ama.ist.model.User)
2017-12-05 19:54:11.703 INFO 480 --- [ 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)
2017-12-05 19:54:11.704 INFO 480 --- [ 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,javax.servlet.http.HttpServletResponse)
2017-12-05 19:54:11.716 INFO 480 --- [ main] o.s.w.s.c.a.WebMvcConfigurerAdapter : Adding welcome page: ServletContext resource [/index.html]
2017-12-05 19:54:11.736 INFO 480 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Root mapping to handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2017-12-05 19:54:11.745 INFO 480 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-05 19:54:11.745 INFO 480 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-05 19:54:11.778 INFO 480 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-05 19:54:11.878 INFO 480 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-12-05 19:54:11.945 INFO 480 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-12-05 19:54:11.949 INFO 480 --- [ main] com.ama.ist.WebApplication : Started WebApplication in 3.254 seconds (JVM running for 3.827)
Project Structure as an image

Finally I got a solution. I was able to resolve this issue by adding thymeleaf dependency in pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
What is Thymeleaf?
Thymeleaf is a Java library. It is an XML/XHTML/HTML5 template engine that is able to apply a set of transformations to template files in order to display data and/or text produced by your applications.
There is one correction required in your html file:
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.5/angular-material.min.css">
make sure to close this tag <link> with end tag </link>. Otherwise you will get below error
There was an unexpected error (type=Internal Server Error,
status=500). Exception parsing document: template="index", line 12 -
column 3
Project structure

Related

Request method 'GET' not supported in Dockerized SpringBoot REST api

I have a small spring application as shown below:
package com.example.demo.api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RequestMapping("api/factorial")
#RestController
public class TestApi {
#GetMapping
public long factorial(){
long startTime = System.nanoTime();
int i;
double fact=1;
int number=50;//It is the number to calculate factorial
for(i=1;i<=number;i++){
fact=fact*i;
System.out.println("Factorial of "+i+" is: "+fact);
}
long endTime = System.nanoTime();
return (endTime - startTime);
}
}
I have generated a jar of this application and dockerized it as shown below:
FROM openjdk:8-jdk-alpine
ADD ./demo-0.0.1-SNAPSHOT.jar /usr/src/factorial/
WORKDIR /usr/src/factorial
EXPOSE 8080
CMD java -XX:+PrintFlagsFinal $JAVA_OPTIONS -jar demo-0.0.1-SNAPSHOT.jar
I then run the below command run the docker container
docker run --rm --name factorialContainer -p 8080:8080 -e JAVA_OPTIONS="$(cat jvmFlags.txt)" suleka96/factorial:latest
Then I am trying to make a HTTP request to the REST endpoint using JMeter as shown below
The problem is that when i do this I get an error saying:
org.springframework.web.HttpRequestMethodNotSupportedException:
Request method 'GET' not supported
However, when I run the spring application locally (without dockerizing it)
and send a request from JMeter, the request successfully gets sent.
What am I doing wrong?
Your application is deployed in docker, so it is virtual machine. That is another host with it's own ip address. But you are trying to send GET request to localhost. You should get your docker ip.
Type this to get ip in Mac OS
host> docker-machine ip default
Visit that page https://spring.io/guides/gs/spring-boot-docker/ there's a section about mac os deployment in that knowledge base
The reason behind this has got to be in the logs.
Here's my setup, I changed the controller so it would return json rather than the long primitive:
Controller
#RequestMapping("api/factorial")
#RestController
public class TestApi {
#GetMapping
public Map<String, Long> factorial(){
long startTime = System.nanoTime();
int i;
double fact=1;
int number=50;//It is the number to calculate factorial
for(i=1;i<=number;i++){
fact=fact*i;
System.out.println("Factorial of "+i+" is: "+fact);
}
long endTime = System.nanoTime();
Map<String, Long> res = new HashMap<String, Long>();
res.put("time_in_nanos", (endTime - startTime));
return res;
}
}
Application
#SpringBootApplication(scanBasePackages = "com.example.demo")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
pom
ml 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>1.0</version>
<packaging>jar</packaging>
<properties>
<springboot.version>2.0.8.RELEASE</springboot.version>
</properties>
<dependencies>
<!-- Springboot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${springboot.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${springboot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${springboot.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Docker command line
docker run --rm --name apiTest -p 8080:8080 321225ee07bb
I used your Dockerfile pretty much as is
Log out put from the container:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.8.RELEASE)
2020-02-04 22:55:03.774 INFO 1 --- [ main] com.example.demo.api.Application : Starting Application on 33f1f71d079b with PID 1 (/usr/src/factorial/demo-1.0.jar started by root in /usr/src/factorial)
2020-02-04 22:55:03.796 INFO 1 --- [ main] com.example.demo.api.Application : No active profile set, falling back to default profiles: default
2020-02-04 22:55:04.076 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2f410acf: startup date [Tue Feb 04 22:55:04 GMT 2020]; root of context hierarchy
2020-02-04 22:55:08.891 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-02-04 22:55:09.002 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-02-04 22:55:09.004 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.37
2020-02-04 22:55:09.055 INFO 1 --- [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: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2020-02-04 22:55:09.305 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-02-04 22:55:09.307 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 5236 ms
2020-02-04 22:55:10.617 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2020-02-04 22:55:10.626 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2020-02-04 22:55:10.636 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2020-02-04 22:55:10.641 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2020-02-04 22:55:10.645 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2020-02-04 22:55:10.647 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpTraceFilter' to: [/*]
2020-02-04 22:55:10.649 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2020-02-04 22:55:11.290 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-02-04 22:55:11.658 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2f410acf: startup date [Tue Feb 04 22:55:04 GMT 2020]; root of context hierarchy
2020-02-04 22:55:11.864 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/factorial],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Long> com.example.demo.api.TestApi.factorial()
2020-02-04 22:55:11.879 INFO 1 --- [ 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)
2020-02-04 22:55:11.880 INFO 1 --- [ 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)
2020-02-04 22:55:11.960 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-02-04 22:55:11.962 INFO 1 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-02-04 22:55:12.745 INFO 1 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2020-02-04 22:55:12.787 INFO 1 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2020-02-04 22:55:12.792 INFO 1 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2020-02-04 22:55:12.796 INFO 1 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2020-02-04 22:55:12.950 INFO 1 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2020-02-04 22:55:13.124 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-02-04 22:55:13.135 INFO 1 --- [ main] com.example.demo.api.Application : Started Application in 10.73 seconds (JVM running for 12.233)
What I'd look for is the mapping of the GET request like this:
2020-02-04 22:55:11.864 INFO 1 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/factorial],methods=[GET]}" onto public java.util.Map<java.lang.String, java.lang.Long> com.example.demo.api.TestApi.factorial()

Springboot won't load my HTML page using Thymeleaf

Already been on these topics but haven't worked for me:
Topic1 No #EnableWebMvc annotation in my project
This is the dependency i used for Thymeleaf:
<!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
My new Controller named ViewController
package myrest.Viewcontroller;
//Imports
#Controller
public class ViewController {
public static String uploadDirectory = System.getProperty("user.dir")+"/uploads";
#RequestMapping("/uploadendpoint")
public String uploadPage(Model model)
{
return "uploadView";
}
}
The HTML named uploadView.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8"></meta>
<title>Insert title here</title>
</head>
<body>
<form action = "/upload" method="post" enctype="multipart/form-data">
<input type="file" name="files" multiple>
<input type="submit" value="Upload Files"></input>
</form>
</body>
</html>
Project's structure:
My Comments: I'm still getting a Whitelabel Error Page , at localhost:8082/uploadendpoint
Edit1:
My #SpringBootApplication class
package myrest;
import java.io.File;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import myrest.Viewcontroller.ViewController;
import myrest.controller.MainController;
#SpringBootApplication
public class RemoteapiApplication {
public static void main(String[] args) {
new File(ViewController.uploadDirectory).mkdir();
SpringApplication.run(RemoteapiApplication.class, args);
}
}
application.properties file:
server.port:8082
spring.servlet.multipart.max-file-size=15MB
spring.servlet.multipart.max-request-size=15MB
Server's logs
2020-01-07 14:37:56.708 INFO 9317 --- [ restartedMain] myrest.RemoteapiApplication : Starting RemoteapiApplication on ZenbookPro with PID 9317 (/home/pihill/Documents/workspace-sts-3.9.9.RELEASE/remoteapi/target/classes started by pihill in /home/pihill/Documents/workspace-sts-3.9.9.RELEASE/remoteapi)
2020-01-07 14:37:56.708 INFO 9317 --- [ restartedMain] myrest.RemoteapiApplication : No active profile set, falling back to default profiles: default
2020-01-07 14:37:56.770 WARN 9317 --- [ restartedMain] org.apache.tomcat.util.modeler.Registry : The MBean registry cannot be disabled because it has already been initialised
2020-01-07 14:37:56.781 INFO 9317 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http)
2020-01-07 14:37:56.782 INFO 9317 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-01-07 14:37:56.782 INFO 9317 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.29]
2020-01-07 14:37:56.784 INFO 9317 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-01-07 14:37:56.784 INFO 9317 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 75 ms
2020-01-07 14:37:56.801 INFO 9317 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-01-07 14:37:56.814 INFO 9317 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-01-07 14:37:56.820 INFO 9317 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8082 (http) with context path ''
2020-01-07 14:37:56.820 INFO 9317 --- [ restartedMain] myrest.RemoteapiApplication : Started RemoteapiApplication in 0.119 seconds (JVM running for 2930.389)
2020-01-07 14:37:56.821 INFO 9317 --- [ restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged
2020-01-07 14:37:59.725 INFO 9317 --- [nio-8082-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-01-07 14:37:59.726 INFO 9317 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-01-07 14:37:59.727 INFO 9317 --- [nio-8082-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
Whitelabel error page:
It is like M.Deinum said. You are using Spring Boot so get the benefits from using the starter packages. In the spring-boot-starter-thymleaf package are more dependencies included than just in the org.thymeleaf 3.0.11.RELEASE.
Replace this in your pom.xml:
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
with this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Then it works like charming.
Add dependency in your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Add your Html file in src/main/resource/templates/test.html(select any name)
Then add this with html tag:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
Create a Controller to open your html file:
#Controller
public class DemoController {
#GetMapping("/OpenTestFile")
public String OpenTestFile(Model model) {
return "test";
}
}
Open with this Url:
http://localhost:8082/OpenTestFile
Some times the IDE your using like intelliJ community version will not support MVC, please check with your IDE supports the requirements

Rest Controller not Working

I have initialed spring boot project using start.spring.io and added WEB,JPA,H2 dependencies.
Pom file
<?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.5.10.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-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<!-- <scope>runtime</scope> -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
application.properties
spring.h2.console.enabled=true
security.basic.enabled=false
DemoApplication.java
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
UserController.java
#RestController
public class UserController {
#GetMapping("/hello")
public String hello() {
return "Hello";
}
Console Log
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.10.RELEASE)
2018-02-26 11:24:28.846 INFO 4792 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on RAJAT-PC with PID 4792 (C:\Users\devra\Downloads\Compressed\demo\target\classes started by rajat in C:\Users\devra\Downloads\Compressed\demo)
2018-02-26 11:24:28.855 INFO 4792 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2018-02-26 11:24:29.018 INFO 4792 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6b67034: startup date [Mon Feb 26 11:24:29 IST 2018]; root of context hierarchy
2018-02-26 11:24:30.894 INFO 4792 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$fa7e8c5a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-02-26 11:24:31.720 INFO 4792 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-02-26 11:24:31.737 INFO 4792 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-02-26 11:24:31.740 INFO 4792 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27
2018-02-26 11:24:31.969 INFO 4792 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-02-26 11:24:31.970 INFO 4792 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2957 ms
2018-02-26 11:24:32.307 INFO 4792 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-02-26 11:24:32.308 INFO 4792 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-02-26 11:24:32.309 INFO 4792 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-02-26 11:24:32.309 INFO 4792 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-02-26 11:24:32.310 INFO 4792 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-02-26 11:24:32.311 INFO 4792 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-02-26 11:24:32.313 INFO 4792 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'webServlet' to [/h2-console/*]
2018-02-26 11:24:33.004 INFO 4792 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-02-26 11:24:33.038 INFO 4792 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-02-26 11:24:33.196 INFO 4792 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2018-02-26 11:24:33.199 INFO 4792 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-02-26 11:24:33.202 INFO 4792 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2018-02-26 11:24:33.266 INFO 4792 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-02-26 11:24:33.517 INFO 4792 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2018-02-26 11:24:33.807 INFO 4792 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2018-02-26 11:24:33.816 INFO 4792 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2018-02-26 11:24:33.859 INFO 4792 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-02-26 11:24:34.365 INFO 4792 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6b67034: startup date [Mon Feb 26 11:24:29 IST 2018]; root of context hierarchy
2018-02-26 11:24:34.506 INFO 4792 --- [ 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)
2018-02-26 11:24:34.508 INFO 4792 --- [ 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,javax.servlet.http.HttpServletResponse)
2018-02-26 11:24:34.568 INFO 4792 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-02-26 11:24:34.569 INFO 4792 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-02-26 11:24:34.663 INFO 4792 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-02-26 11:24:35.147 INFO 4792 --- [ main] b.a.s.AuthenticationManagerConfiguration :
Using default security password: dd5212d7-4de1-4fee-9f6b-f5cd888f2f17
2018-02-26 11:24:35.222 INFO 4792 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
2018-02-26 11:24:35.334 INFO 4792 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.boot.autoconfigure.security.SpringBootWebSecurityConfiguration$ApplicationNoWebSecurityConfigurerAdapter$1#11c713b7, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#2251b3bc, org.springframework.security.web.context.SecurityContextPersistenceFilter#602f8f94, org.springframework.security.web.header.HeaderWriterFilter#2785db06, org.springframework.security.web.csrf.CsrfFilter#603cabc4, org.springframework.security.web.authentication.logout.LogoutFilter#7a9ceddf, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#4dfe8b37, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#7e64c1a9, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#3fbe503c, org.springframework.security.web.session.SessionManagementFilter#715a70e9, org.springframework.security.web.access.ExceptionTranslationFilter#1cc8416a]
2018-02-26 11:24:35.552 INFO 4792 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-02-26 11:24:35.652 INFO 4792 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-02-26 11:24:35.670 INFO 4792 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 7.302 seconds (JVM running for 7.824)
as you can see spring didn't mapped the /hello url
Considering that the other answers don't explain why it doesn't work as expected, here's why.
Spring uses component scanning to find eligible beans (#Repository, #Service, #Component, #Controller, ...). This is usually done by using the #ComponentScan annotation.
This is explained in the core docs:
To autodetect these classes and register the corresponding beans, you need to add #ComponentScan to your #Configuration class, where the basePackages attribute is a common parent package for the two classes. (Alternatively, you can specify a comma/semicolon/space-separated list that includes the parent package of each class.)
Spring Boot, by default only scans components within the same package (and including subpackages) of the main class. This is because the #SpringBootApplication annotation includes a #ComponentScanby default, as mentioned in the Spring boot docs:
The #SpringBootApplication annotation is equivalent to using #Configuration, #EnableAutoConfiguration and #ComponentScan with their default attributes
If you want Spring to automatically detect your controller, you have three options:
Move the controller to the com.example.demo package. This is the recommended approach according to the Spring boot documentation.
Telling Spring to look at the controller package by adding a #ComponentScan annotation:
#SpringBootApplication
#ComponentScan({"com.example.demo", "controller"}) // Add this
public class DemoApplication {
// ...
}
Telling Spring to look at the controller package by configuring the scanBasePackages property of #SpringBootApplication:
#SpringBootApplication(scanBasePackages = {"com.example.demo", "controller"}) // Add this
public class DemoApplication {
// ...
}
Spring reference doc says - Generally recommend that you locate your main application class in a root package above other classes like
com
+- example
+- myproject
+- Application.java
|
+- domain
| +- Customer.java
| +- CustomerRepository.java
|
+- service
| +- CustomerService.java
|
+- web
+- CustomerController.java
For more refer this link :
https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-structuring-your-code.html

All Spring-Boot Application always show a popup login

I'm using Spring and Spring Boot framework with Spring Security for a simple login projects with simple UI. In all my projects, using STS, after starting my application and run the localhost address without errors, i receive a popup login window and not my html page.
If i use user and default security password i always get a Whitelabel Error Page as results. Furthermore, if i use incorrect value the popup remain, if instead i use the default access value i get this message.
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Aug 23 20:14:22 CEST 2017
There was an unexpected error (type=Not Found, status=404).
No message available
Here is a simple project code. All the html files are in template folder as you can see in project structure. I also try to use server.error.whitelabel.enabled=false in my application.properties file.`
Why has the html interface never been shown?
Project Structure
Application
package com.cyberdemon.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class SpringbootUiLoginApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootUiLoginApplication.class, args);
}
}
SecurityConfig
package config;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
#Configuration
#EnableAutoConfiguration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Autowired
DataSource dataSource;
#Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery("select username,password, enabled from users where username=?")
.authoritiesByUsernameQuery("select username, role from user_roles where username=?");
}
#Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/", "/home").permitAll().antMatchers("/admin").hasRole("ADMIN")
.anyRequest().authenticated().and().formLogin().loginPage("/login").permitAll().and().logout()
.permitAll();
http.exceptionHandling().accessDeniedPage("/403");
}
}
WebController
package controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class WebController {
#RequestMapping(value = { "/", "home" })
public String home() {
return "home";
}
#RequestMapping(value = { "/welcome" })
public String welcome() {
return "welcome";
}
#RequestMapping(value = "/admin")
public String admin() {
return "admin";
}
#RequestMapping(value = { "/login" })
public String login() {
return "login";
}
#RequestMapping(value = "/403")
public String Error403() {
return "403";
}
}
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.cyberdemon.springboot</groupId>
<artifactId>springboot_UI_Login</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springboot_UI_Login</name>
<description>Project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.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-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-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>
properties
spring.datasource.url=jdbc:mysql://localhost:3306/testdb
spring.datasource.username=root
spring.datasource.password=toor
Console
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.6.RELEASE)
2017-08-23 19:57:05.949 INFO 7496 --- [ main] c.c.s.SpringbootUiLoginApplication : Starting SpringbootUiLoginApplication on DESKTOP-CYBERDEMON with PID 7496 (started by GD in C:\Users\me\Documents\workspace-sts\springboot_ui_login)
2017-08-23 19:57:05.949 INFO 7496 --- [ main] c.c.s.SpringbootUiLoginApplication : No active profile set, falling back to default profiles: default
2017-08-23 19:57:06.121 INFO 7496 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6cc7b4de: startup date [Wed Aug 23 19:57:06 CEST 2017]; root of context hierarchy
2017-08-23 19:57:07.293 INFO 7496 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-08-23 19:57:07.300 INFO 7496 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-08-23 19:57:07.300 INFO 7496 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-08-23 19:57:07.409 INFO 7496 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-08-23 19:57:07.409 INFO 7496 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1288 ms
2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2017-08-23 19:57:07.566 INFO 7496 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-08-23 19:57:07.847 INFO 7496 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6cc7b4de: startup date [Wed Aug 23 19:57:06 CEST 2017]; root of context hierarchy
2017-08-23 19:57:07.894 INFO 7496 --- [ 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)
2017-08-23 19:57:07.894 INFO 7496 --- [ 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,javax.servlet.http.HttpServletResponse)
2017-08-23 19:57:07.925 INFO 7496 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-23 19:57:07.925 INFO 7496 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-23 19:57:07.956 INFO 7496 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-23 19:57:08.519 INFO 7496 --- [ main] b.a.s.AuthenticationManagerConfiguration :
Using default security password: 21cf3953-b4e3-48ac-87fa-9041c41b3ff8
2017-08-23 19:57:08.567 INFO 7496 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
2017-08-23 19:57:08.645 INFO 7496 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#12fcc71f, org.springframework.security.web.context.SecurityContextPersistenceFilter#5d43409a, org.springframework.security.web.header.HeaderWriterFilter#76563d26, org.springframework.security.web.authentication.logout.LogoutFilter#102ecc22, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#4eba373c, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#6ede46f6, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#10a0fe30, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#5679e96b, org.springframework.security.web.session.SessionManagementFilter#23b8d9f3, org.springframework.security.web.access.ExceptionTranslationFilter#261ea657, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#6cd64ee8]
2017-08-23 19:57:08.864 INFO 7496 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-08-23 19:57:08.911 INFO 7496 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-08-23 19:57:08.926 INFO 7496 --- [ main] c.c.s.SpringbootUiLoginApplication : Started SpringbootUiLoginApplication in 3.164 seconds (JVM running for 3.428)
2017-08-23 19:57:24.008 INFO 7496 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-08-23 19:57:24.008 INFO 7496 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2017-08-23 19:57:24.021 INFO 7496 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 13 ms
You need to restructure your packages to that they fall under the package of your SpringbootUiLoginApplication or use #ComponentScan to tell the Spring Boot where to find your bean classes.
Following up on Ali's answer:
#SpringBootApplication implies #Configuration , #EnableAutoConfiguration and #ComponentScan
So, consider changing:
#Configuration
#EnableAutoConfiguration
public class SecurityConfig extends WebSecurityConfigurerAdapter
to:
#Component
public class SecurityConfig extends WebSecurityConfigurerAdapter
And to scan for beans in your entire package change:
#SpringBootApplication
public class SpringbootUiLoginApplication
to:
#SpringBootApplication
#ComponentScan("com.cyberdemon")
public class SpringbootUiLoginApplication
I got this when I didn't realize another Spring Boot application was running on port 8080. End that and you won't get that security modal.

How to configure spring-boot with embedded Tomcat to work as a single application?

I have application which after mvn clean package -U tomcat7:run works as soap web service and wsdl is available on: http://localhost:8080/appservices/ws?wsdl
Now my aim to compile a single jar which will provide web service after execute java -jar service.jar.
As I know spring-boot decides this task.
I created an Application class:
package com.comp.service;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
#Configuration
#ComponentScan
#EnableAutoConfiguration
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
But after I execute mvn spring-boot:run and call url http://localhost:8080/appservices/ws?wsdl I receive:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Fri Feb 05 14:54:11 MSK 2016
There was an unexpected error (type=Not Found, status=404).
No message available
Spring's start log:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.2.RELEASE)
2016-02-05 14:43:45.012 INFO 21008 --- [ main] com.comp.service.Application : Starting Application on PCwith PID 21008 (C:\Users\Maya\git\app-services\target\classes started by Maya in C:\Users\Maya\git\app-services
-services)
2016-02-05 14:43:45.017 INFO 21008 --- [ main] com.comp.service.Application : No active profile set, falling back to default profiles: default
2016-02-05 14:43:45.117 INFO 21008 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#5dc33359: startup date [Fri Feb 05 14:43:45 MSK 2016]; root o
f context hierarchy
2016-02-05 14:43:46.344 INFO 21008 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=fal
se; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; des
troyMethodName=(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; depen
dencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); de
fined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2016-02-05 14:43:47.363 INFO 21008 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-02-05 14:43:47.386 INFO 21008 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-02-05 14:43:47.388 INFO 21008 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.30
2016-02-05 14:43:47.555 INFO 21008 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-02-05 14:43:47.559 INFO 21008 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2448 ms
2016-02-05 14:43:48.048 INFO 21008 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-02-05 14:43:48.055 INFO 21008 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-02-05 14:43:48.055 INFO 21008 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-02-05 14:43:48.056 INFO 21008 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-02-05 14:43:48.057 INFO 21008 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-02-05 14:43:48.475 INFO 21008 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#5dc33359: startup date [Fri Feb 05 14:43:
45 MSK 2016]; root of context hierarchy
2016-02-05 14:43:48.589 INFO 21008 --- [ 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.autoconfigur
e.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-02-05 14:43:48.592 INFO 21008 --- [ 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.BasicErrorControlle
r.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-02-05 14:43:48.639 INFO 21008 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-02-05 14:43:48.639 INFO 21008 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-02-05 14:43:48.694 INFO 21008 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-02-05 14:43:48.869 INFO 21008 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-02-05 14:43:48.967 INFO 21008 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-02-05 14:43:48.972 INFO 21008 --- [ main] com.comp.service.Application : Started Application in 4.428 seconds (JVM running for 11.125)
2016-02-05 14:44:02.085 INFO 21008 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-02-05 14:44:02.086 INFO 21008 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-02-05 14:44:02.107 INFO 21008 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 21 ms
Where is my problem? In Application.class?
My pom:
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdkName>JavaSE-1.7</jdkName>
<jdk.version>1.7</jdk.version>
<spring-boot.version>1.3.2.RELEASE</spring-boot.version>
<spring.version>4.2.4.RELEASE</spring.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port>
<extraDependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.0.7</version>
</dependency>
</extraDependencies>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>${spring-boot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.10</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>
Thank you for any advice.
UPDATE
May be problem in web.xml?:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
<web-app>
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>WSServlet</servlet-name>
<servlet-class>
<!--com.sun.xml.ws.transport.http.servlet.WSServlet-->
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WSServlet</servlet-name>
<url-pattern>/ws</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
</web-app>
UPDATE 1:
Application class:
#SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Configuration:
#Configuration
#EnableAutoConfiguration
public class AppConfig {
#Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.setPort(9000);
factory.setSessionTimeout(10, TimeUnit.MINUTES);
factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notfound.html"));
return factory;
}
}
spring-boot:run log:
2016-02-08 10:26:19.733 INFO 3976 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-02-08 10:26:19.758 INFO 3976 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2016-02-08 10:26:19.990 INFO 3976 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9000 (http)
2016-02-08 10:26:19.998 INFO 3976 --- [ main] com.comp.service.Application : Started Application in 5.911 seconds (JVM running for 15.537)
2016-02-08 10:26:53.130 INFO 3976 --- [nio-9000-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-02-08 10:26:53.130 INFO 3976 --- [nio-9000-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-02-08 10:26:53.156 INFO 3976 --- [nio-9000-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 26 ms

Categories