Jdbctemplate could not find it when configuring jdbc with spring mvc.

when writing spring mvc using idea and maven, configuring jdbc to run later indicates that jdbcTemplate cannot be found.

error prompt:

2018-04-11 22:37:07.936  WARN 10096 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name "helloController": Unsatisfied dependency expressed through field "t"; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name "test": Unsatisfied dependency expressed through field "jdbcTemplate"; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type "org.springframework.jdbc.core.JdbcTemplate" available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2018-04-11 22:37:07.938  INFO 10096 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-04-11 22:37:07.953  INFO 10096 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with "debug" enabled.
2018-04-11 22:37:08.024 ERROR 10096 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field jdbcTemplate in cqupt.stu.automaker.dao.test required a bean of type "org.springframework.jdbc.core.JdbcTemplate" that could not be found.


Action:

Consider defining a bean of type "org.springframework.jdbc.core.JdbcTemplate" in your configuration.


Process finished with exit code 1

dependency has been injected into
clipboard.png

clipboard.png

clipboard.png

import cqupt.stu.automaker.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

@Service
public class test {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public List<User> getList(){
        String sql = "SELECT * FORM USER WHERE USERID = 1";
        return (List<User>)jdbcTemplate.query(sql, new RowMapper<User>() {
            @Override
            public User mapRow(ResultSet rs, int rowNum) throws SQLException {
                User user = new User();
                user.setUserid(rs.getInt("userid"));
                user.setPassword(rs.getString("password"));
                user.setUsername(rs.getString("username"));
                return user;
            }
        });
    }
    
}

Mar.02,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bc9981-3099b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bc9981-3099b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?