[JAVA] Error in Spring database connection

Error in the sequence of flow in the database

I used it as a teaching material

Going forward and getting an error when connecting to the URL

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private jp.co.kenshu.service.TestService jp.co.kenshu.controller.TestController.testService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [jp.co.kenshu.service.TestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1116)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
	org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:651)
	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:599)
	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:665)
	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:518)
	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459)
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
	org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:745)

<!--Omitted below-->

What was dealt with

The mvc-config.xml file could not be described properly

mvc-config.xml


<!--Only the error part is described-->

<!-- Uncomment and your base-package here:   -->
<context:component-scan base-package="jp.co.kenshu.controller"/>

I made a mistake in the specification here, so I changed it and fixed it.

mvc-config.xml



<!-- Uncomment and your base-package here:   -->
<context:component-scan base-package="jp.co.kenshu"/>

Recommended Posts

Error in Spring database connection
Store session information in database in Spring Session
MySql connection error
MySQL error in Spring Unknown column'Value 1'in'field list'
Inject Logger in Spring
Use Interceptor in Spring
Error handling in Graphql-ruby
Get cookies in Spring
I tried using a database connection in Android development
Database environment construction with Docker in Spring boot (IntellJ)
Set context-param in Spring Boot
Spring + MyBatis connection setting method
Spring validation and error code
Avoid Yubaba's error in Java
NameError in Income # index error
About Spring Framework context error
ActiveRecord :: NotNullViolation in Devise error
Error in rails db: migrate
npm error in docker tutorial
Get error information using DefaultErrorAttributes and ErrorAttributeOptions in Spring Boot 2.3
Major changes in Spring Boot 1.5
NoHttpResponseException in Spring Boot + WireMock
Spring Boot DB connection pool
Loop step in Spring Batch
Unknown error in line 1 of pom.xml when using Spring Boot in Eclipse
How to use Lombok in Spring
Call Chain from Chain in Spring Integration
Spring Boot Hello World in Eclipse
Spring Boot application development in Eclipse
Spring Boot + PostgreSQL error resolution method
Java Spring environment in vs Code
Write test code in Spring Boot
[Rails] Unexpected validation error in devise
I participated in JJUG CCC 2019 Spring
About Invalid Request Error in Payjp
Create a database in a production environment
Implement reCAPTCHA v3 in Java / Spring
411 Error: Length Required in SOAP communication
Error handling in gRPC (Kotlin version)
Implement REST API in Spring Boot
Event processing is performed in Spring.
Implement Spring Boot application in Gradle
HTTPS connection using tls1.2 in Java 6
Error in ./gradlew: Symbol not found
Error summary in bundle install. memorandum
About error when implementing spring validation
Error encountered in tagging function implementation
Thymeleaf usage notes in Spring Boot
Spring Boot + MyBatis I get this error if I don't set the database
How to get the setting value (property value) from the database in Spring Framework
I want to display an error message when registering in the database