Spring Accessing data with MySQL Won't Run - java

I'm new to using Spring, and I'm going through the accessing-data-with-MySQL tutorial here. I'm using Eclipse, and when I download all the code for the project, and then run the project as a Spring Boot App, I get the error:
APPLICATION FAILED TO START
Description:
Field userRepository in hello.MainController required a bean of type 'hello.UserRepository' that could not be found.
Action:
Consider defining a bean of type 'hello.UserRepository' in your configuration.
Again, this is the code directly from the tutorial. Anybody have any idea what's going on?
Thanks!
Full run log
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.6.RELEASE)
2017-08-26 21:58:28.365 INFO 2308 --- [ main] hello.Application : Starting Application on DESKTOP-F9F09K7 with PID 2308 (C:\Users\dylan\Desktop\gs-accessing-data-mysql-master\complete\target\classes started by dylan in C:\Users\dylan\Desktop\gs-accessing-data-mysql-master\complete)
2017-08-26 21:58:28.367 INFO 2308 --- [ main] hello.Application : No active profile set, falling back to default profiles: default
2017-08-26 21:58:28.411 INFO 2308 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#6b53e23f: startup date [Sat Aug 26 21:58:28 PDT 2017]; root of context hierarchy
2017-08-26 21:58:29.454 INFO 2308 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-08-26 21:58:29.465 INFO 2308 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-08-26 21:58:29.466 INFO 2308 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-08-26 21:58:29.542 INFO 2308 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-08-26 21:58:29.542 INFO 2308 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1135 ms
2017-08-26 21:58:29.655 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-08-26 21:58:29.659 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-08-26 21:58:29.667 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-08-26 21:58:29.667 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-08-26 21:58:29.667 INFO 2308 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-08-26 21:58:29.701 WARN 2308 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainController': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'hello.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
2017-08-26 21:58:29.703 INFO 2308 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-08-26 21:58:29.721 INFO 2308 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-08-26 21:58:29.804 ERROR 2308 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field userRepository in hello.MainController required a bean of type 'hello.UserRepository' that could not be found.
Action:
Consider defining a bean of type 'hello.UserRepository' in your configuration.

I was able to fix this problem by clearing my maven cache. I did this by manually deleting my:
C:\Users\username\ .m2
folder and then doing a clean install. What the problem was, how it developed, and what changed to fix it I/we may never know. But, things seem to be working again.
Thanks to all who helped!

Have you registered a repository with type UserRepository? Check if you sign the repository with a #Repository annotation.

Download project from git gs-accessing-data-mysql-master
Extract the file to your disk
Open Eclipse
Click File > Import > Existing Maven Projects > Next
Click Browse and select the gs-accessing-data-mysql-master folder that is on your disk and Next
Select both pom.xml and Finish
Open gs-mysql-data project that has been imported
Right click on Application.java and run as Java Application or Spring Boot Application
Make sure that UserRepository interface extends from CrudRepository, like this:
package hello;
import org.springframework.data.repository.CrudRepository;
import hello.User;
// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository
// CRUD refers Create, Read, Update, Delete
public interface UserRepository extends CrudRepository<User, Long> {
}

Related

Update your application's configuration in Spring Boot

Update your application's configuration in Spring Boot error when I am running a Spring Boot Application.
The maven is built successfully, but still the error persists.
What should I do to change overcome this error?
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.M4)
2018-06-08 12:45:36.422 INFO 8904 --- [ main] com.lankydan.Application : Starting Application on GH-6C9HNH2 with PID 8904 (C:\Users\E080978\Downloads\Maven\spring-boot-hateoas-master\target\classes started by E080978 in C:\Users\E080978\Downloads\Maven\spring-boot-hateoas-master)
2018-06-08 12:45:36.426 INFO 8904 --- [ main] com.lankydan.Application : No active profile set, falling back to default profiles: default
2018-06-08 12:45:36.484 INFO 8904 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2805c96b: startup date [Fri Jun 08 12:45:36 IST 2018]; root of context hierarchy
2018-06-08 12:45:37.897 INFO 8904 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3a19c841] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-06-08 12:45:38.652 INFO 8904 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8090 (http)
2018-06-08 12:45:38.672 INFO 8904 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-06-08 12:45:38.673 INFO 8904 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.20
2018-06-08 12:45:38.818 INFO 8904 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-06-08 12:45:38.818 INFO 8904 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2337 ms
2018-06-08 12:45:39.020 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-06-08 12:45:39.025 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-06-08 12:45:39.025 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-06-08 12:45:39.026 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-06-08 12:45:39.026 INFO 8904 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-06-08 12:45:39.075 WARN 8904 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Unsatisfied dependency expressed through method 'dataSource' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties': prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.password' to java.lang.String
2018-06-08 12:45:39.077 INFO 8904 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-06-08 12:45:39.098 INFO 8904 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-06-08 12:45:39.103 ERROR 8904 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Binding to target [Bindable#6bff19ff type = java.lang.String, value = 'provided', annotations = array<Annotation>[[empty]]] failed:
Property: spring.datasource.password
Value: ${password}
Origin: class path resource [application.properties]:7:28
Reason: Could not resolve placeholder 'password' in value "${password}"
Action:
Update your application's configuration
You have to turn on filtering for your maven resources plugin. You have to add a <filtering> tag to your POM and set it to true.
The ${password} variable possibly needs to be replaced with the real password by maven, during the "process resources" phase
For further info see:
https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
It looks like you have not declared the property 'password' (or there's something wrong with it's declaration) that you're trying to use in 'spring.datasource.password' property.
It's hard to tell, though, without seeing the whole properties file.
The error is because your application can't find the env variable password. If this problem only happens on you local machine, simply specify a default value when the env var is not present. Like this:
spring.datasource.password: ${password:local-password}
(Change local-password to the real password of your local database.)
If it happens in your test or prod environment, you have to inject it into your server's environment variables, or contact the DevOps guy to help you do that.
In my case removing below from pom.xml fixed the issue
<resources>
<resource>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/resources/</directory>
<targetPath>${project.build.directory}/config/</targetPath>
<includes>
<include>application.properties</include>
</includes>
</resource>
</resources>

spring boot related issues

Spring boot issues with following code. see error below and tomcat is running fine
package com.template;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class SpringBootFreemarkerApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootFreemarkerApplication.class,
args);
}
}
package controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
#Controller
public class TestController {
#RequestMapping("/welcome")
public String hello(Model model, #RequestParam(value="name",
required=false, defaultValue="World") String name) {
model.addAttribute("name", name);
return "welcome";
}
}
"C:\Program Files\Java\jdk1.8.0_121\bin\java" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.1.5\lib\idea_rt.jar=54267:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.1.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_121\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_121\jre\lib\rt.jar;C:\SpringBoot\Spring-boot-freemarker\target\classes;C:\Users\shekhar\.m2\repository\org\springframework\boot\spring-boot-starter-freemarker\1.5.6.RELEASE\spring-boot-starter-freemarker-1.5.6.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\boot\spring-boot-starter\1.5.6.RELEASE\spring-boot-starter-1.5.6.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\boot\spring-boot\1.5.6.RELEASE\spring-boot-1.5.6.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.6.RELEASE\spring-boot-autoconfigure-1.5.6.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\boot\spring-boot-starter-logging\1.5.6.RELEASE\spring-boot-starter-logging-1.5.6.RELEASE.jar;C:\Users\shekhar\.m2\repository\ch\qos\logback\logback-classic\1.1.11\logback-classic-1.1.11.jar;C:\Users\shekhar\.m2\repository\ch\qos\logback\logback-core\1.1.11\logback-core-1.1.11.jar;C:\Users\shekhar\.m2\repository\org\slf4j\jcl-over-slf4j\1.7.25\jcl-over-slf4j-1.7.25.jar;C:\Users\shekhar\.m2\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;C:\Users\shekhar\.m2\repository\org\slf4j\log4j-over-slf4j\1.7.25\log4j-over-slf4j-1.7.25.jar;C:\Users\shekhar\.m2\repository\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;C:\Users\shekhar\.m2\repository\org\freemarker\freemarker\2.3.26-incubating\freemarker-2.3.26-incubating.jar;C:\Users\shekhar\.m2\repository\org\springframework\spring-context-support\4.3.10.RELEASE\spring-context-support-4.3.10.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\spring-beans\4.3.10.RELEASE\spring-beans-4.3.10.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\spring-context\4.3.10.RELEASE\spring-context-4.3.10.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\boot\spring-boot-starter-web\1.5.6.RELEASE\spring-boot-starter-web-1.5.6.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\1.5.6.RELEASE\spring-boot-starter-tomcat-1.5.6.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.16\tomcat-embed-core-8.5.16.jar;C:\Users\shekhar\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.16\tomcat-embed-el-8.5.16.jar;C:\Users\shekhar\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.16\tomcat-embed-websocket-8.5.16.jar;C:\Users\shekhar\.m2\repository\org\hibernate\hibernate-validator\5.3.5.Final\hibernate-validator-5.3.5.Final.jar;C:\Users\shekhar\.m2\repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;C:\Users\shekhar\.m2\repository\org\jboss\logging\jboss-logging\3.3.1.Final\jboss-logging-3.3.1.Final.jar;C:\Users\shekhar\.m2\repository\com\fasterxml\classmate\1.3.3\classmate-1.3.3.jar;C:\Users\shekhar\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.9\jackson-databind-2.8.9.jar;C:\Users\shekhar\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.8.0\jackson-annotations-2.8.0.jar;C:\Users\shekhar\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.9\jackson-core-2.8.9.jar;C:\Users\shekhar\.m2\repository\org\springframework\spring-web\4.3.10.RELEASE\spring-web-4.3.10.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\spring-aop\4.3.10.RELEASE\spring-aop-4.3.10.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\spring-webmvc\4.3.10.RELEASE\spring-webmvc-4.3.10.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\springframework\spring-expression\4.3.10.RELEASE\spring-expression-4.3.10.RELEASE.jar;C:\Users\shekhar\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\shekhar\.m2\repository\org\springframework\spring-core\4.3.10.RELEASE\spring-core-4.3.10.RELEASE.jar" com.template.SpringBootFreemarkerApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.6.RELEASE)
2017-07-30 15:20:08.005 INFO 7612 --- [ main] c.t.SpringBootFreemarkerApplication : Starting SpringBootFreemarkerApplication on DESKTOP-9LIAED5 with PID 7612 (C:\SpringBoot\Spring-boot-freemarker\target\classes started by shekhar in C:\SpringBoot\Spring-boot-freemarker)
2017-07-30 15:20:08.008 INFO 7612 --- [ main] c.t.SpringBootFreemarkerApplication : No active profile set, falling back to default profiles: default
2017-07-30 15:20:08.074 INFO 7612 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#3bd94634: startup date [Sun Jul 30 15:20:08 IST 2017]; root of context hierarchy
2017-07-30 15:20:10.322 INFO 7612 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-30 15:20:10.333 INFO 7612 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-07-30 15:20:10.334 INFO 7612 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-07-30 15:20:10.472 INFO 7612 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-07-30 15:20:10.472 INFO 7612 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2398 ms
2017-07-30 15:20:10.788 INFO 7612 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-07-30 15:20:10.792 INFO 7612 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-07-30 15:20:10.792 INFO 7612 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-07-30 15:20:10.793 INFO 7612 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-07-30 15:20:10.793 INFO 7612 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-07-30 15:20:11.221 INFO 7612 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#3bd94634: startup date [Sun Jul 30 15:20:08 IST 2017]; root of context hierarchy
2017-07-30 15:20:11.299 INFO 7612 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/welcome]}" onto public java.lang.String com.template.controller.TestController.hello(org.springframework.ui.Model,java.lang.String)
2017-07-30 15:20:11.302 INFO 7612 --- [ 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-07-30 15:20:11.302 INFO 7612 --- [ 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-07-30 15:20:11.337 INFO 7612 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-30 15:20:11.337 INFO 7612 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-30 15:20:11.374 INFO 7612 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-30 15:20:11.626 INFO 7612 --- [ main] o.s.w.s.v.f.FreeMarkerConfigurer : ClassTemplateLoader for Spring macros added to FreeMarker configuration
2017-07-30 15:20:11.727 INFO 7612 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-07-30 15:20:11.790 INFO 7612 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-07-30 15:20:11.795 INFO 7612 --- [ main] c.t.SpringBootFreemarkerApplication : Started SpringBootFreemarkerApplication in 4.222 seconds (JVM running for 5.046)
Your controller is not scanned by the default component scan that Spring Boot provides. By default Spring boot starts from the package that contains the "main" class - the one annotated with #SpringBootApplication and also scans all of it's sub packages.
Your main class is in package com.template; but the controller is in package controller;. Move the controller in a package named package com.template.controller;
Since you are using FreeMarker Template with spring boot, I would suggest you to move your welcome.ftl template from this location src/webapp/welcome.ftl to this src/main/resources/templates/welcome.ftl and then restart your application and hit http://localhost:8080/welcome

Errors creating multiple database entities in Spring/hibernate

Attempting to make a spring application with multiple databases in spring-boot. MY orm is hibernate and below I have a copy of my application.properties files and my print trace. Thanks for any help in advance:
spring.ds_toner.url = jdbc:mysql://localhost:3306/toner_stock?useSSL=false
spring.ds_toner.username=toner
spring.ds_toner.password=toner
spring.ds_toner.driver-class-name=com.mysql.jdbc.Driver
spring.ds_manager.url=jdbc:mysql://localhost:3306/toner_manager?useSSL=false
spring.ds_manager.username=toner
spring.ds_manager.password=toner
spring.ds_manager.driver-class-name= com.mysql.jdbc.Driver
spring.ds_buyer.url= jdbc:mysql://localhost:3306/toner_buyer?useSSL=false
spring.ds_buyer.username=toner
spring.ds_buyer.password=toner
spring.ds_buyer.driver-class-name= com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.show-sql=true
spring.jpa.hibernate.dialect= org.hibernate.dialect.MySQL55Dialect
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
Print Trace:
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=52449:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/lib/tools.jar:/Users/ronaldpitt/Desktop/TonerStock/target/classes:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.2.RELEASE/spring-boot-starter-web-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.2.RELEASE/spring-boot-starter-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot/1.5.2.RELEASE/spring-boot-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.2.RELEASE/spring-boot-autoconfigure-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.2.RELEASE/spring-boot-starter-logging-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar:/Users/ronaldpitt/.m2/repository/ch/qos/logback/logback-core/1.1.11/logback-core-1.1.11.jar:/Users/ronaldpitt/.m2/repository/org/slf4j/jul-to-slf4j/1.7.24/jul-to-slf4j-1.7.24.jar:/Users/ronaldpitt/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.24/log4j-over-slf4j-1.7.24.jar:/Users/ronaldpitt/.m2/repository/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.2.RELEASE/spring-boot-starter-tomcat-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.11/tomcat-embed-core-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.11/tomcat-embed-el-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.11/tomcat-embed-websocket-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/hibernate-validator/5.3.4.Final/hibernate-validator-5.3.4.Final.jar:/Users/ronaldpitt/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/Users/ronaldpitt/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.7/jackson-databind-2.8.7.jar:/Users/ronaldpitt/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar:/Users/ronaldpitt/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.7/jackson-core-2.8.7.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-web/4.3.7.RELEASE/spring-web-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-aop/4.3.7.RELEASE/spring-aop-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-context/4.3.7.RELEASE/spring-context-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-webmvc/4.3.7.RELEASE/spring-webmvc-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-expression/4.3.7.RELEASE/spring-expression-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-core/4.3.7.RELEASE/spring-core-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-thymeleaf/1.5.2.RELEASE/spring-boot-starter-thymeleaf-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/thymeleaf/thymeleaf-spring4/2.1.5.RELEASE/thymeleaf-spring4-2.1.5.RELEASE.jar:/Users/ronaldpitt/.m2/repository/nz/net/ultraq/thymeleaf/thymeleaf-layout-dialect/1.4.0/thymeleaf-layout-dialect-1.4.0.jar:/Users/ronaldpitt/.m2/repository/org/codehaus/groovy/groovy/2.4.9/groovy-2.4.9.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/hibernate-core/5.2.9.Final/hibernate-core-5.2.9.Final.jar:/Users/ronaldpitt/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar:/Users/ronaldpitt/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar:/Users/ronaldpitt/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/ronaldpitt/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.1.Final/jboss-transaction-api_1.2_spec-1.0.1.Final.jar:/Users/ronaldpitt/.m2/repository/org/jboss/jandex/2.0.3.Final/jandex-2.0.3.Final.jar:/Users/ronaldpitt/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar:/Users/ronaldpitt/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.0.1.Final/hibernate-commons-annotations-5.0.1.Final.jar:/Users/ronaldpitt/.m2/repository/org/springframework/data/spring-data-commons/1.13.1.RELEASE/spring-data-commons-1.13.1.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-beans/4.3.7.RELEASE/spring-beans-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/slf4j/slf4j-api/1.7.24/slf4j-api-1.7.24.jar:/Users/ronaldpitt/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.24/jcl-over-slf4j-1.7.24.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/1.5.2.RELEASE/spring-boot-starter-data-jpa-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-aop/1.5.2.RELEASE/spring-boot-starter-aop-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar:/Users/ronaldpitt/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.5.2.RELEASE/spring-boot-starter-jdbc-1.5.2.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.5.11/tomcat-jdbc-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/apache/tomcat/tomcat-juli/8.5.11/tomcat-juli-8.5.11.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-jdbc/4.3.7.RELEASE/spring-jdbc-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar:/Users/ronaldpitt/.m2/repository/org/springframework/data/spring-data-jpa/1.11.1.RELEASE/spring-data-jpa-1.11.1.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-orm/4.3.7.RELEASE/spring-orm-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-tx/4.3.7.RELEASE/spring-tx-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/springframework/spring-aspects/4.3.7.RELEASE/spring-aspects-4.3.7.RELEASE.jar:/Users/ronaldpitt/.m2/repository/mysql/mysql-connector-java/5.1.39/mysql-connector-java-5.1.39.jar:/Users/ronaldpitt/.m2/repository/org/hibernate/hibernate-entitymanager/5.2.9.Final/hibernate-entitymanager-5.2.9.Final.jar:/Users/ronaldpitt/.m2/repository/net/bytebuddy/byte-buddy/1.6.6/byte-buddy-1.6.6.jar:/Users/ronaldpitt/.m2/repository/org/thymeleaf/thymeleaf-spring3/3.0.3.RELEASE/thymeleaf-spring3-3.0.3.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/thymeleaf/thymeleaf/2.1.5.RELEASE/thymeleaf-2.1.5.RELEASE.jar:/Users/ronaldpitt/.m2/repository/org/unbescape/unbescape/1.1.0.RELEASE/unbescape-1.1.0.RELEASE.jar com.ronone.Application
objc[6848]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java (0x10eb834c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1103f14e0). One of the two will be used. Which one is undefined.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.2.RELEASE)
2017-05-11 21:12:08.760 INFO 6848 --- [ main] com.ronone.Application : Starting Application on Ronalds-MacBook-Pro.local with PID 6848 (/Users/ronaldpitt/Desktop/TonerStock/target/classes started by ronaldpitt in /Users/ronaldpitt/Desktop/TonerStock)
2017-05-11 21:12:08.763 INFO 6848 --- [ main] com.ronone.Application : No active profile set, falling back to default profiles: default
2017-05-11 21:12:09.015 INFO 6848 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#77be656f: startup date [Thu May 11 21:12:09 EDT 2017]; root of context hierarchy
2017-05-11 21:12:10.645 INFO 6848 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$578c281f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-05-11 21:12:11.075 INFO 6848 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-05-11 21:12:11.108 INFO 6848 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-05-11 21:12:11.110 INFO 6848 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.11
2017-05-11 21:12:11.267 INFO 6848 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-05-11 21:12:11.267 INFO 6848 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2258 ms
2017-05-11 21:12:11.465 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-05-11 21:12:11.471 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-05-11 21:12:11.472 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-05-11 21:12:11.473 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-05-11 21:12:11.473 INFO 6848 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-05-11 21:12:11.532 WARN 6848 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
2017-05-11 21:12:11.534 INFO 6848 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-05-11 21:12:11.547 WARN 6848 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
2017-05-11 21:12:11.561 INFO 6848 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-05-11 21:12:11.569 ERROR 6848 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
The reason for the exception is
Cannot determine embedded database driver class for database type NONE.
If you want an embedded database please put a supported one on the
classpath. If you have database settings to be loaded from a particular
profile you may need to active it (no profiles are currently active).
Spring autoconfiguration is creating only one DataSource and expects properties as
spring.datasource.url=jdbc:mysql://localhost/test
spring.datasource.username=dbuser
spring boot reference
You do not set these properties, so spring tries to create a datasource without url, which leads to the exception.
You need to create additional DataSources yourself, you may find this post helpfull.

When Is My Business Code Actually Being Executed?

I got a Spring Boot app. It's running as such:
#SpringBootApplication
public class MyBooty implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(MyBooty.class, args);
}
public void run(String... args) throws Exception {
SomeClass someClass = new SomeClass(...);
someClass.doStuff();
System.out.println("Why Am I appearing Before \"Started In\" log line?");
}
Does what I need. But I noticed this line in the output: Started MyBooty in 17.594 seconds (JVM running for 18.206), which was printed after some of my console output.
This made me think my code was actually executing before the app was actually initialized. So I did some research found this blog post and then set up a new class as such:
#Component
public class ApplicationStartup implements ApplicationListener<ApplicationReadyEvent>{
public void onApplicationEvent(ApplicationReadyEvent event) {
SomeClass someClass = new SomeClass(...);
SomeClass.doStuff();
return;
}
}
Which supposedly executes after after application startup. Well, I still see the Started app in... output after my output again.
So, concept check. Are things working as intended and I'm just being naive? Or is there maybe something missing? If someone could knowledge share on the topic that would be appreciated.
Again, my code runs and does exactly what I need it to, but I just want to make sure I'm using/taking advantage of Spring Boot properly.
In case it's unclear what I'm asking, I'm asking Why does the "Started App in X seconds" message appear after my output? I ask this because I simply found it confusing that it said the app was started after my business code had ALREADY ran. This question is a conceptual question about how spring boot starts up.
Edit: Console Output
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.2.RELEASE)
2016-09-23 17:44:56.598 INFO 1004 --- [ main] o.b.p.MyBooty : Starting MyBooty on ********* with PID **** (C:\...\MyBooty)
:
:
:
2016-09-23 17:44:59.152 INFO 1004 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-09-23 17:44:59.154 INFO 1004 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.30
2016-09-23 17:44:59.725 INFO 1004 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-09-23 17:44:59.725 INFO 1004 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3074 ms
2016-09-23 17:45:00.228 INFO 1004 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-09-23 17:45:00.234 INFO 1004 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-09-23 17:45:00.234 INFO 1004 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-09-23 17:45:00.234 INFO 1004 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-09-23 17:45:00.234 INFO 1004 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-09-23 17:45:00.824 INFO 1004 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#453da22c: startup date [Fri Sep 23 17:44:56 CDT 2016]; root of context hierarchy
2016-09-23 17:45:00.901 INFO 1004 --- [ 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)
2016-09-23 17:45:00.902 INFO 1004 --- [ 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)
2016-09-23 17:45:00.925 INFO 1004 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-23 17:45:00.925 INFO 1004 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-23 17:45:00.962 INFO 1004 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-09-23 17:45:01.136 INFO 1004 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-09-23 17:45:01.215 INFO 1004 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
Why Am I appearing Before "Started In" log line?
2016-09-23 17:45:17.063 INFO 1004 --- [ main] o.b.p.MyBooty : Started MyBooty in 20.814 seconds (JVM running for 23.279) <----- Why is this after my output?
2016-09-23 17:45:22.675 INFO 1004 --- [)-10.168.50.106] inMXBeanRegistrar$SpringApplicationAdmin : Application shutdown requested.
2016-09-23 17:45:22.676 INFO 1004 --- [)-10.168.50.106] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#453da22c: startup date [Fri Sep 23 17:44:56 CDT 2016]; root of context hierarchy
2016-09-23 17:45:22.678 INFO 1004 --- [)-10.168.50.106] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
You class is annotated with #SpringBootApplication, which makes it automatically register as a Spring Bean.
The SpringApplication run(Object source, String... args) method you are calling ends up calling run(String... args).
The run() method calls the afterRefresh() method right before it logs the "Started ..." message, and afterRefresh() will call the run() method of any registered ApplicationRunner and CommandLineRunner beans.
Or, as the documentation says it:
If you need to run some specific code once the SpringApplication has started, you can implement the ApplicationRunner or CommandLineRunner interfaces. Both interfaces work in the same way and offer a single run method which will be called just before SpringApplication.run(…​) completes.

install spring boot CLI in windows 7

I would like to set up a dev environment on my Windows 7 machine so i can create a spring-boot application. However, i'm having a hard time installing Spring-boot on windows.
This is what i have done so far:
-Downloaded spring-boot CLI zip package and unzipped in C drive
-JAVA_HOME variable set to c:\Program Files (x86)\Java\jdk1.6.0_14
-SPRING_HOME variable set to C:\spring-1.3.0.BUILD-SNAPSHOT
-Added SPRING_HOME/bin to PATH environment variable
It says to add symlink to auto-completion script but i do not know how to do that. Not surprisingly when i test installation with "spring --version" command, it fails.
Anybody has done this before?
Thanks!
Instructions for setup are bit misleading for path setup.
For Windows, Environment variables section, need use %SPRING_HOME%\bin referencing in place of SPRING_HOME/bin for the system to pick up SPRING_HOME environment variable.
Where SPRING_HOME is an environment variable for specifying path to the spring boot directory.
E.g. :- C:\Program Files\Spring\spring-1.2.7.RELEASE
Note: bin folder is not included in the SPRING_HOME.
I was able to get it up, here are screen grabs of process.
Alternatively you can have the path setup directly without SPRING_HOME, just append the environment variable path with directory path of your "spring.bat" file C:\Program Files\Spring\spring-1.2.7.RELEASE\bin;.
Windows looks in the current directory before searching the path. So, when you're in the bin directory it sees the spring command there and does not look at the path.
1.MANUALLY INSTALLING THE SPRING BOOT CLI
spring-boot-cli-2.0.0.M1-bin.zip is installed.
2.Extract spring-boot-cli-2.0.0.M1-bin.zip.
3.After spring-2.0.0.M1 extractd.
4. Direct command prompt
--------------------------
C:\Users\nepl>spring --version
'spring' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\nepl>E:
E:\>cd Nagarjuna
E:\Nagarjuna>cd "spring applications"
E:\Nagarjuna\spring applications>cd spring-2.0.0.M1
E:\Nagarjuna\spring applications\spring-2.0.0.M1>cd bin
E:\Nagarjuna\spring applications\spring-2.0.0.M1\bin>spring -- version
'--' is not a valid command. See 'help'.
E:\Nagarjuna\spring applications\spring-2.0.0.M1\bin>spring --version
Spring CLI v2.0.0.M1
E:\Nagarjuna\spring applications\spring-2.0.0.M1\bin>spring --help
E:\Nagarjuna\spring applications\spring-2.0.0.M1\bin>spring run HelloWorld.groov
y
Resolving dependencies......................................................
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.M1)
2017-12-15 15:36:07.949 INFO 3464 --- [ runner-0] o.s.boot.SpringApplicat
ion : Starting application on nw0188 with PID 3464 (started by nep
l in E:\Nagarjuna\spring applications\spring-2.0.0.M1\bin)
2017-12-15 15:36:07.996 INFO 3464 --- [ runner-0] o.s.boot.SpringApplicat
ion : No active profile set, falling back to default profiles: def
ault
2017-12-15 15:36:08.689 INFO 3464 --- [ runner-0] ConfigServletWebServerA
pplicationContext : Refreshing org.springframework.boot.web.servlet.context.Anno
tationConfigServletWebServerApplicationContext#48cd5e87: startup date [Fri Dec 1
5 15:36:08 IST 2017]; root of context hierarchy
2017-12-15 15:36:11.575 INFO 3464 --- [ runner-0] o.s.b.w.embedded.tomcat
.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2017-12-15 15:36:11.606 INFO 3464 --- [ runner-0] o.apache.catalina.core.
StandardService : Starting service [Tomcat]
2017-12-15 15:36:11.606 INFO 3464 --- [ runner-0] org.apache.catalina.cor
e.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-12-15 15:36:12.285 INFO 3464 --- [ost-startStop-1] org.apache.catalina.loa
der.WebappLoader : Unknown loader org.springframework.boot.cli.compiler.Extende
dGroovyClassLoader$DefaultScopeParentClassLoader#526a6c66 class org.springframew
ork.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2017-12-15 15:36:12.378 INFO 3464 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[loc
alhost].[/] : Initializing Spring embedded WebApplicationContext
2017-12-15 15:36:12.378 INFO 3464 --- [ost-startStop-1] o.s.web.context.Context
Loader : Root WebApplicationContext: initialization completed in 3689
ms
2017-12-15 15:36:12.550 INFO 3464 --- [ost-startStop-1] o.s.b.w.servlet.Servlet
RegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-12-15 15:36:12.550 INFO 3464 --- [ost-startStop-1] o.s.b.w.servlet.FilterR
egistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-12-15 15:36:12.550 INFO 3464 --- [ost-startStop-1] o.s.b.w.servlet.FilterR
egistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-12-15 15:36:12.550 INFO 3464 --- [ost-startStop-1] o.s.b.w.servlet.FilterR
egistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-12-15 15:36:12.550 INFO 3464 --- [ost-startStop-1] o.s.b.w.servlet.FilterR
egistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-12-15 15:36:13.070 INFO 3464 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.
servlet.context.AnnotationConfigServletWebServerApplicationContext#48cd5e87: sta
rtup date [Fri Dec 15 15:36:08 IST 2017]; root of context hierarchy
2017-12-15 15:36:13.200 INFO 3464 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/]}" onto public java.util.Map HelloWorld.home()
2017-12-15 15:36:13.209 INFO 3464 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.Res
ponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframewo
rk.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet
.http.HttpServletRequest)
2017-12-15 15:36:13.209 INFO 3464 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.spr
ingframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web
.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequ
est,javax.servlet.http.HttpServletResponse)
2017-12-15 15:36:13.242 INFO 3464 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class or
g.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-15 15:36:13.242 INFO 3464 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.spring
framework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-15 15:36:13.289 INFO 3464 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [clas
s org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-12-15 15:36:13.976 INFO 3464 --- [ runner-0] o.s.j.e.a.AnnotationMBe
anExporter : Registering beans for JMX exposure on startup
2017-12-15 15:36:14.170 INFO 3464 --- [ runner-0] o.s.b.w.embedded.tomcat
.TomcatWebServer : Tomcat started on port(s): 8080 (http)
2017-12-15 15:36:14.175 INFO 3464 --- [ runner-0] o.s.boot.SpringApplicat
ion : Started application in 8.06 seconds (JVM running for 77.714)
2017-12-15 15:37:42.225 INFO 3464 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[loc
alhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-12-15 15:37:42.226 INFO 3464 --- [nio-8080-exec-1] o.s.web.servlet.Dispatc
herServlet : FrameworkServlet 'dispatcherServlet': initialization started
2017-12-15 15:37:42.249 INFO 3464 --- [nio-8080-exec-1] o.s.web.servlet.Dispatc
herServlet : FrameworkServlet 'dispatcherServlet': initialization complet
ed in 23 ms

Categories

Resources