亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

視頻里面的代碼不完整,搞了很久,導致查詢結果是null,完整代碼如下:

視頻里面的代碼不完整,搞了很久,導致查詢結果是null,完整代碼如下:


package com.imooc.demo.config.dao;


import org.mybatis.spring.SqlSessionFactoryBean;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.annotation.Qualifier;

import org.springframework.beans.factory.annotation.Value;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.Configuration;

import org.springframework.core.io.ClassPathResource;

import org.springframework.core.io.support.PathMatchingResourcePatternResolver;

import javax.sql.DataSource;

import java.io.IOException;


@Configuration

public class SessionFactoryConfiguration {

? ? private static String mybatisConfigFile;

? ? @Value("${mybatis_config_file}")

? ? public void setMybatisConfigFile(String mybatisConfigFile) {

? ? ? ? SessionFactoryConfiguration.mybatisConfigFile = mybatisConfigFile;

? ? }



? ? private static String mapperPath;

? ? @Value("${mapper_path}")

? ? public void setMapperPath(String mapperPath) {

? ? ? ? SessionFactoryConfiguration.mapperPath = mapperPath;

? ? }


? ? @Value("${entity_package}")

? ? private String entityPackage;


? ? @Autowired

? ? @Qualifier("dataSource")

? ? private DataSource dataSource;


? ? @Bean(name = "sqlSessionFactory")

? ? public SqlSessionFactoryBean createSqlSessionFactoryBean() throws IOException {

? ? ? ? SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();

? ? ? ? sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(mybatisConfigFile));

? ? ? ? PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();

? ? ? ? String packageSearchPath = PathMatchingResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + mapperPath;

? ? ? ? sqlSessionFactoryBean.setMapperLocations(resolver.getResources(packageSearchPath));

? ? ? ? sqlSessionFactoryBean.setDataSource(dataSource);

? ? ? ? sqlSessionFactoryBean.setTypeAliasesPackage(entityPackage);

? ? ? ? return sqlSessionFactoryBean;

? ? }

}


正在回答

舉報

0/150
提交
取消

視頻里面的代碼不完整,搞了很久,導致查詢結果是null,完整代碼如下:

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號