pom文件
org.apache.hive hive-jdbc2.1.1 org.eclipse.jetty.aggregate *com.alibaba druid-spring-boot-starter1.1.23 org.springframework.boot spring-boot-starter-jdbccom.baomidou mybatis-plus-boot-starter3.4.0
注意hive-jdbc版本一定与hive目录下的lib目录当中的jdbc版本一致
application.yml
spring:
datasource:
driver-class-name: org.apache.hive.jdbc.HiveDriver
url: jdbc:hive2://自己的地址啦:10000/default
username: root
password:
logging:
level:
com.example.hive.mapper: debug
Mapper
public interface CityWeatherMapper extends baseMapper{ List getall(); }
select key,cityname,humidity,pyName,state1,state2,stateDetailed,tem1,tem2,temNow,time,url,windDir,windPower,windState from weather_city_five_minutes_jinzhou_hive
注意一定不要写select * from tableName 返回的对应不上实体类要将所有字段写出
@RestController
@RequestMapping("/city")
public class CityWeatherController {
@Resource
CityWeatherMapper cityWeatherMapper;
@GetMapping("getWeather")
public List a(){
// List cityWeathers = cityWeatherMapper.selectList(null);
List getall = cityWeatherMapper.getall();
return getall;
}
}



