org.springframework.beans.factory.support.DefaultListableBeanFactory类型无法解析

时间:2018-02-23 08:08:54

标签: java spring-mvc spring-boot spring-data

Config build path包spring.java.config;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import spring.java.domail.BlogPost;
import spring.java.domail.DataSource;
import spring.java.services.BlogpostService;

public class MainApplication {
    private static final Logger LOGGER = LoggerFactory.getLogger(MainApplication.class);

    public static void main(String[] args) {
    //  ApplicationContext applicationContext = new AnnotationConfigApplicationContext(JavaConfig.class);
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(JavaConfig.class);
        BlogpostService blogPostService = applicationContext.getBean(BlogpostService.class);
        // BlogpostService blogPostService =(BlogpostService)
        // appContext.getBean("blogpostSrervice");

        BlogPost post = new BlogPost();
        post.setContent("Hello Sajan");
        post.setDraft(true);
        post.setId(10);
        post.setPublisgDate(new Date());
        post.setTitle("Blog Post Title");
        blogPostService.savePost(post);

        DataSource dataSource = applicationContext.getBean(DataSource.class);

        LOGGER.debug("dataSource: url " + dataSource.getUrl());
        LOGGER.debug("dataSource: username " + dataSource.getUsername());
        LOGGER.debug("dataSource: password " + dataSource.getPassword());

        ((ConfigurableApplicationContext) applicationContext).close();
    }

}

运行应用程序时出错。 我还在Click Here Fore Scrren Short下面附上屏幕短裤 给我这个错误的解决方案。 我将项目转移到另一台计算机时遇到此错误。

2 个答案:

答案 0 :(得分:0)

  1. 您可以通过单击“配置构建路径”并为项目配置构建路径来解决此问题,这仅适用于此计算机。移动到另一台计算机时需要进行配置。

  2. 您可以向pom.xml添加依赖项,让maven为您管理依赖项。这将一直有效。

    library(RODBC)
    server <- "servername\REP"
    database<- "databasename"
    connectionString <- paste0("Driver={SQL Server};server=",server,";database=",database,";trusted_connection=yes;")
    channel <-  odbcDriverConnect(connection=connectionString)
    

答案 1 :(得分:0)

关闭Eclipse - &gt; 转到C:\ Users \ sajan \ m2 \ repository并删除所有文件夹和文件,然后再次更新Maven并清理它。

相关问题