When I run my spring boot application in eclipse 4.7.3 IDE, the console doesn't display the information about the rest controller. Nevertheless the controller is working when I test it with browser.
It is just a "Hello World" application:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class HelloWorldSpringBootApp {
public static void main(String[] args) {
SpringApplication.run(HelloWorldSpringBootApp.class, args);
}
}
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class HelloWorldController {
#RequestMapping(value = "/")
public String helo() {
return "Hello World!";
}
}
Output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-28 09:08:33.768 INFO 2208 --- [ main] c.infotech.app.HelloWorldSpringBootApp : Starting HelloWorldSpringBootApp on OfficeLaptop01 with PID 2208 (C:\Users\Admin\eclipse-workspace4.7.3a\Sprang\HelloWorldSpringBoot\target\classes started by Admin in C:\Users\Admin\eclipse-workspace4.7.3a\Sprang\HelloWorldSpringBoot)
2019-04-28 09:08:33.775 INFO 2208 --- [ main] c.infotech.app.HelloWorldSpringBootApp : No active profile set, falling back to default profiles: default
2019-04-28 09:08:34.852 INFO 2208 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-04-28 09:08:34.873 INFO 2208 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-28 09:08:34.873 INFO 2208 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-04-28 09:08:34.978 INFO 2208 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-28 09:08:34.978 INFO 2208 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1157 ms
2019-04-28 09:08:35.183 INFO 2208 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-04-28 09:08:35.348 INFO 2208 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-04-28 09:08:35.351 INFO 2208 --- [ main] c.infotech.app.HelloWorldSpringBootApp : Started HelloWorldSpringBootApp in 1.904 seconds (JVM running for 2.561)
As above it just display until "Started HelloWorldSpringBootApp in 1.904 seconds" without the request mapping status & mapped URL path info. Why?
The log output was changed in Spring 2.1. That changelog states that
If you are trying to debug an application and you want to restore
Spring Boot 2.0 style logging you should add the following to your
application.properties
logging.level.web=debug
This change however does not output what I would expect given this RestController
#RestController
public class HelloWorldController {
#RequestMapping(value = "/hello")
public String hello() {
return "Hello World!";
}
}
If I set the log level to trace it gives the expected output (though not in the exact same way as Spring Boot 2.1).
10:53:26.427 [main] TRACE o.s.w.s.m.m.a.RequestMappingHandlerMapping -
c.i.e.d.r.HelloWorldController:
{ /hello}: hello()
The requirement for trace log level is most likely due to a change in Spring Framework 5.1 (see release note)
Related
I'm working on a Spring Boot 2.2.1 project. I use Gradle 6.8.3 as a dependency manager, I'm new to working with Gradle as a deps manager and it's my first time using the h2 engine.
This is my gradle file
plugins {
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.somedomain'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-web'
}
test {
useJUnitPlatform()
}
In my application.properties I have a path that points to memory H2
application.properties
spring.datasource.url=jdbc:h2:mem:~/biblioteca
Cuando ejecuto mi aplicación, e ingreso la url me genera la siguiente excepción:
IO Exception: null
IO Exception: null [90028-200] 90028/90028 (Help)
I've searched for this on the internet for a few hours, and I have no information about it, something leads me to believe that Gradle is not taking my dependencies. When I bring up my server I get the following in the powershell
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.1.RELEASE)
2022-09-07 17:01:40.086 INFO 8612 --- [ main]
c.c.biblioteca.BibliotecaApplication : Starting BibliotecaApplication
on LAPTOP-4E9PK22R with PID 8612
(C:\Users\tomas\OneDrive\Escritorio\projects\proyect\biblioteca\bin\main started by
tomas in C:\Users\tomas\OneDrive\Escritorio\projects\proyect\biblioteca)
2022-09-07 17:01:40.093 INFO 8612 --- [ main]
c.c.biblioteca.BibliotecaApplication : No active profile set, falling
back to default profiles: default
2022-09-07 17:01:42.423 INFO 8612 --- [ main]
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-09-07 17:01:42.613 INFO 8612 --- [ main]
o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-09-07 17:01:42.692 INFO 8612 --- [ main]
org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache
Tomcat/9.0.27]
2022-09-07 17:01:43.227 INFO 8612 --- [ main] o.a.c.c.C.[Tomcat].[localhost].
[/] : Initializing Spring embedded WebApplicationContext
2022-09-07 17:01:43.229 INFO 8612 --- [ main] o.s.web.context.ContextLoader
: Root WebApplicationContext: initialization completed in 2874 ms
2022-09-07 17:01:43.829 INFO 8612 --- [ main]
o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService
'applicationTaskExecutor'
2022-09-07 17:01:44.318 INFO 8612 --- [ main]
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with
context path ''
2022-09-07 17:01:44.328 INFO 8612 --- [ main]
c.c.biblioteca.BibliotecaApplication : Started BibliotecaApplication in 5.386
seconds (JVM running for 6.59)
Should dependencies be shown here if I'm not wrong? I already tried with mvn clean
install and the server continues to get up the same
Add other h2 properties needed to connect to the database in application.properties
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=
I just have set up a Spring Boot Application and wanted to test, if the tomcat server will return a blank page, but instead, it throwed the following error massage in my IDE:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.2)
2021-02-16 14:21:45.297 INFO 6956 --- [ main] com.test.gifly.GiflyApplication : Starting GiflyApplication using Java 15.0.2 on LAPTOP-LJRSO4L6 with PID 6956 (D:\Coding\gifly\build\classes\java\main started by Dominik Lovetinsky in D:\Coding\gifly)
2021-02-16 14:21:45.302 INFO 6956 --- [ main] com.test.gifly.GiflyApplication : No active profile set, falling back to default profiles: default
2021-02-16 14:21:46.102 INFO 6956 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-02-16 14:21:46.119 INFO 6956 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-02-16 14:21:46.120 INFO 6956 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-02-16 14:21:46.211 INFO 6956 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-02-16 14:21:46.212 INFO 6956 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 859 ms
2021-02-16 14:21:46.367 INFO 6956 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-16 14:21:46.545 INFO 6956 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-02-16 14:21:46.554 INFO 6956 --- [ main] com.test.gifly.GiflyApplication : Started GiflyApplication in 1.607 seconds (JVM running for 2.285)
2021-02-16 14:22:00.025 INFO 6956 --- [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x010x020x000x010x000x010xfc0x030x030x870x97`F0xe7Q[0x960x02<0xe40xde]\0x06l0xc3G0xfa0xcc0x8d0x0d0x00X0xca;V0x160x9a0xef0xca0xc1]. HTTP method names must be tokens
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:417) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]
2021-02-16 14:22:00.025 INFO 6956 --- [nio-8080-exec-2] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
The only code i have already specified, is the main java class, and the following Controller class:
package com.test.gifly.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
#Controller
public class GifController {
#RequestMapping(value = "/")
#ResponseBody
public String listGifs(){
return "List fo all the GIFs!";
}
}
Does anyone know, where this error comes from and how to fix it?
It also seems like, that my request mapping is not working.
Can you try to change #RequestMapping to #GetMapping? Also check if you are going to the website starting with https instead of http
I have this service in github https://github.com/felloz/personsService The application compile with no errors but when im trying to access the route http://localhost:8080/demo/persons Im getting this error:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon May 11 14:55:30 VET 2020
There was an unexpected error (type=Not Found, status=404).
No message available
The compile message:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.7.RELEASE)
2020-05-11 15:05:55.576 INFO 10476 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on lserrano-PC with PID 10476 (C:\JAVA\Eclipse Projects\demo\target\classes started by lserrano in C:\JAVA\Eclipse Projects\demo)
2020-05-11 15:05:55.592 INFO 10476 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2020-05-11 15:05:58.173 INFO 10476 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-05-11 15:05:58.198 INFO 10476 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-11 15:05:58.198 INFO 10476 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.34]
2020-05-11 15:05:58.386 INFO 10476 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-05-11 15:05:58.387 INFO 10476 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2685 ms
2020-05-11 15:05:58.857 INFO 10476 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2020-05-11 15:05:59.362 INFO 10476 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-05-11 15:05:59.377 INFO 10476 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 4.578 seconds (JVM running for 5.433)
2020-05-11 15:06:14.712 INFO 10476 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-11 15:06:14.712 INFO 10476 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-05-11 15:06:14.727 INFO 10476 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 15 ms
You can check the code in the github repo, Im new with Sprong any help will be appreciated, im using NetBeans as IDE.
After adding server.servlet.context-path=/demo
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.7.RELEASE)
2020-05-11 17:26:54.336 INFO 9144 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on lserrano-PC with PID 9144 (C:\JAVA\Eclipse Projects\demo\target\classes started by lserrano in C:\JAVA\Eclipse Projects\demo)
2020-05-11 17:26:54.336 INFO 9144 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2020-05-11 17:26:56.926 INFO 9144 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-05-11 17:26:56.957 INFO 9144 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-05-11 17:26:56.957 INFO 9144 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.34]
2020-05-11 17:26:57.160 INFO 9144 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/demo] : Initializing Spring embedded WebApplicationContext
2020-05-11 17:26:57.160 INFO 9144 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2715 ms
2020-05-11 17:26:57.612 INFO 9144 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2020-05-11 17:26:58.111 INFO 9144 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '/demo'
2020-05-11 17:26:58.111 INFO 9144 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 4.591 seconds (JVM running for 5.464)
2020-05-11 17:27:14.361 INFO 9144 --- [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/demo] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-11 17:27:14.362 INFO 9144 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-05-11 17:27:14.379 INFO 9144 --- [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 17 ms
you have #RequestMapping({"/persons"}) in your controller, so try this link http://localhost:8080/persons without demo
after spring 2 , context path configuration has been changed ;
server.servlet.context-path=/demo
And then try http://localhost:8080/demo/persons
If you don't want to use Jpa, following changes would be needed :
Context Path should be set as:
server.servlet.context-path=/demo
DemoApplication Class (correcting base package):
#SpringBootApplication
#ComponentScan(basePackages = {"com.example"})
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
You need to provide the implementation for your Repositoory:
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Repository;
#Repository
public class PersonRepository{
public List<Person> findAll(){
List<Person> list = new ArrayList<>();
Person person = new Person();
person.setId(10001);
person.setName("Name");
person.setLastname("LastName");
list.add(person);
return list;
}
}
To work with MySQL DB and SpringBoot , you can find many example on web. Please follow that. Example : SpringBootMySQLExample
There is good question about ability to add multiple tomcat connectors and bind them to separate controllers each.
The essense of Andy Wilkinson's good answer is here:
public static void main(String[] args) {
SpringApplicationBuilder parentBuilder
= new SpringApplicationBuilder(ApplicationConfiguration.class);
parentBuilder.child(ServiceOneConfiguration.class)
.properties("server.port:8080").run(args);
parentBuilder.child(ServiceTwoConfiguration.class)
.properties("server.port:8081").run(args);
}
I want to go on this futher and ask another question:
Is there a way to make each child application context to read some child specific application properties with support of all standard spring-boot's features, like profile-suffix file names etc.
One hypothetical way to achieve it:
Have three separate property files:
application.properties
child1.properties
child2.properties
And have ability to set one file for each context.
But what is important to me, that they must support all spring-boot magic. For example, if I activate new profile like passing command line argument --spring.profiles.active=dev, then automagically not only these three files should be loaded (one for each context), but another set of files (if they exist) also should be loaded automatically:
application-dev.properties
child1-dev.properties
child2-dev.properties
Of course, these files should be searched at standard spring-boot's supported paths in defined order etc.
Is it possible out if the box of maybe with some coding?
Another hypothetical way to achieve it
Have only one application.properties file (with support for profiles etc), but somehow to map prefixed properties to unprefixed properties of child contexts.
Example:
child1.server.port=8081
child1.foo=bar
child2.server.port=8082
child2.foo=baz
First child context should see these properties like if they were just:
server.port=8081
foo=bar
Second child context should see these properties like if they were just:
server.port=8082
foo=baz
So, standard spring-boot's autoconfigurations will work and correctly set tomcat's port etc.
I am not looking for specific approach (but if you ask me, I'm leaning towards second approach), but any working out-of-the-box or achievable with minimum conding apporach will suffice me.
You can achieve your first suggestion using spring.config.name:
public static void main(String[] args) {
SpringApplicationBuilder parentBuilder =
new SpringApplicationBuilder(ParentApplication.class)
.web(WebApplicationType.NONE);
parentBuilder.run(args);
parentBuilder.child(ServiceOneConfiguration.class)
.properties("spring.config.name=child1").run(args);
parentBuilder.child(ServiceTwoConfiguration.class)
.properties("spring.config.name=child2").run(args);
}
You can then use child1{-profile}.properties and child2{-profile}.properties to configure service one and service two respectively.
For example, with server.port=8081 in child1.properties and server.port=8082 in child2.properties, you should see output similar to the following when starting an app that's using auto-configuration in the two child services and has a dependency on spring-boot-starter-web:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2019-01-22 13:38:09.690 INFO 80968 --- [ main] com.example.parent.ParentApplication : Starting ParentApplication on …
2019-01-22 13:38:09.692 INFO 80968 --- [ main] com.example.parent.ParentApplication : No active profile set, falling back to default profiles: default
2019-01-22 13:38:09.842 INFO 80968 --- [ main] com.example.parent.ParentApplication : Started ParentApplication in 0.371 seconds (JVM running for 0.644)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2019-01-22 13:38:10.046 INFO 80968 --- [ main] com.example.parent.ParentApplication : No active profile set, falling back to default profiles: default
2019-01-22 13:38:10.584 INFO 80968 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2019-01-22 13:38:10.604 INFO 80968 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-01-22 13:38:10.605 INFO 80968 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14]
2019-01-22 13:38:10.613 INFO 80968 --- [ main] 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/awilkinson/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2019-01-22 13:38:10.668 INFO 80968 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-01-22 13:38:10.668 INFO 80968 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 612 ms
2019-01-22 13:38:10.829 INFO 80968 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-01-22 13:38:10.981 INFO 80968 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path ''
2019-01-22 13:38:10.981 INFO 80968 --- [ main] com.example.parent.ParentApplication : Started ParentApplication in 0.955 seconds (JVM running for 1.784)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2019-01-22 13:38:11.003 INFO 80968 --- [ main] com.example.parent.ParentApplication : No active profile set, falling back to default profiles: default
2019-01-22 13:38:11.093 INFO 80968 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http)
2019-01-22 13:38:11.095 INFO 80968 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-01-22 13:38:11.096 INFO 80968 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14]
2019-01-22 13:38:11.100 INFO 80968 --- [ main] o.a.c.c.C.[Tomcat-1].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-01-22 13:38:11.101 INFO 80968 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 97 ms
2019-01-22 13:38:11.135 INFO 80968 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-01-22 13:38:11.164 INFO 80968 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8082 (http) with context path ''
2019-01-22 13:38:11.165 INFO 80968 --- [ main] com.example.parent.ParentApplication : Started ParentApplication in 0.183 seconds (JVM running for 1.967)
I follow Spring Boot Reference Guide and got this error
HTTP Status [404] – [Not Found]
Type Status Report
Message /
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Here is the code
#RestController
class ThisWillActuallyRun {
#RequestMapping("/")
String home() {
"Hello World!"
}
}
Command that I run.
spring run app.groovy
Console log that I got.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.4.RELEASE)
2017-07-21 14:37:37.474 INFO 47637 --- [ runner-0] o.s.boot.SpringApplication : Starting application on MacBook-Pro-2016.local with PID 47637 (started by moss in /Users/moss/java_ws/hello)
2017-07-21 14:37:37.477 INFO 47637 --- [ runner-0] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default
2017-07-21 14:37:37.659 INFO 47637 --- [ runner-0] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#3a0184b7: startup date [Fri Jul 21 14:37:37 ICT 2017]; root of context hierarchy
2017-07-21 14:37:38.831 INFO 47637 --- [ runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-21 14:37:38.844 INFO 47637 --- [ runner-0] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-07-21 14:37:38.846 INFO 47637 --- [ runner-0] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-07-21 14:37:38.923 INFO 47637 --- [ost-startStop-1] org.apache.catalina.loader.WebappLoader : Unknown loader org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader#c0454ed class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2017-07-21 14:37:38.950 INFO 47637 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-07-21 14:37:38.951 INFO 47637 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1296 ms
2017-07-21 14:37:39.020 INFO 47637 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-07-21 14:37:39.605 INFO 47637 --- [ runner-0] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-07-21 14:37:39.674 INFO 47637 --- [ runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-07-21 14:37:39.678 INFO 47637 --- [ runner-0] o.s.boot.SpringApplication : Started application in 12.556 seconds (JVM running for 14.572)
Did I do something wrong?
I just use sdkman switch back to Spring CLI v1.5.3.RELEASE and it's work.