Configuration conf = new Configuration(); conf.setEnvironment( new Environment.Builder("only") .transactionFactory(new JdbcTransactionFactory()) .dataSource(new PooledDataSource( "com.mysql.jdbc.Driver", "jdbc:mysql://127.0.0.1:3306/xxx_rule_engine", "root", "123456" )).build()); conf.addMapper(PrizeMapper.class); SqlSessionFactory ssf = new SqlSessionFactoryBuilder().build(conf); SqlSession openSession = ssf.openSession(); PrizeMapper mapper = openSession.getMapper(PrizeMapper.class); List<PrizeModel> list = mapper.list(new PrizeModel()); System.out.println(list);
时间: 2024-10-31 09:43:12