结构如图:

\"\"

 

public class EntInfBean{

          private String AAA;

          private String BBB;

         ... ...

}

@Configuration
@ComponentScan(\"xxx\")
@MapperScan(\"xxx.dao\")
public class DataConfig {

    @Bean
    public DataSource dataSource(){
        BasicDataSource dataSource = new BasicDataSource();

        dataSource.setDriverClassName(\"com.microsoft.sqlserver.jdbc.SQLServerDriver\");
    
        dataSource.setUrl(\"jdbc:sqlserver://xx.xx.xx.xx;Data Name=xxx\");
        dataSource.setUsername(\"xxxname\");
        dataSource.setPassword(\"xxxpd\");
   
        return dataSource;
    }

    @Bean
    public SqlSessionFactoryBean sqlSessionFactoryBean() throws Exception{
        SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
        sessionFactory.setDataSource(dataSource());
        //sessionFactory.setTypeAliasesPackage(\"xxx.bean\");
        return sessionFactory;
    }
}
@Mapper
public interface EntInfMapper {

      ... ...
}
public interface EntInfService {
    String xxx(EntInfBean entInfBean);
}
@Service
public class EntInfServiceImpl implements EntInfService {
    private static final Logger logger = LoggerFactory.getLogger(EntInfServiceImpl.class);
    @Autowired
    private final EntInfMapper entInfMapper;
    public EntInfServiceImpl(EntInfMapper entInfMapper){
        this.entInfMapper = entInfMapper;
    }

    public String xxx(EntInfBean entInfBean){
       ... ...
    }
}

这样设置,就不需要在 文件中进行配置了。

收藏 打印