jboot和 springCloud
时间: 2023-10-30 19:47:04 浏览: 45
jboot和Spring Cloud都是基于Java的开源框架,用于构建分布式系统和微服务架构。
jboot是一个基于JFinal的轻量级框架,它提供了一些便于开发分布式应用的工具和组件,例如Dubbo, ZooKeeper, Apollo等。jboot的目标是简化分布式应用开发,提高开发效率和运行效率。
Spring Cloud是一个由Pivotal开发的微服务框架,它是Spring框架的延伸。Spring Cloud提供了一组工具和组件,例如Eureka, Zuul, Hystrix等,用于构建并管理分布式应用。Spring Cloud的目标是简化微服务架构开发,提高弹性和可靠性。
虽然jboot和Spring Cloud都可以用于构建分布式系统和微服务架构,但它们的侧重点和设计思路略有不同。jboot更注重简化开发过程和提高运行效率,而Spring Cloud更注重弹性和可靠性。具体选择哪个框架需要根据具体的业务需求和团队技术实力来决定。
相关问题
jboot部署的详细步骤
jboot 是一个基于 Java 开发的轻量级框架,它的部署步骤如下:
1. 安装 JDK 和 Maven
jboot 需要依赖 JDK 和 Maven,因此需要先安装它们。
2. 创建 Maven 项目
在命令行中进入要创建项目的目录,执行以下命令:
```
mvn archetype:generate -DgroupId=com.example -DartifactId=my-jboot-app -DarchetypeGroupId=io.jboot -DarchetypeArtifactId=jboot-web-archetype -DinteractiveMode=false
```
其中,`com.example` 和 `my-jboot-app` 分别是项目的包名和项目名。
3. 运行项目
进入项目目录,执行以下命令:
```
mvn jboot:run
```
4. 部署项目
可以将项目打包成 war 包,然后部署在 Tomcat 或者 Jetty 等 Web 容器中。执行以下命令可以打包项目:
```
mvn package
```
然后将生成的 war 包复制到 Web 容器的 webapps 目录下即可。
以上就是 jboot 的部署步骤。需要注意的是,jboot 还支持 Docker 部署,可以根据具体情况选择部署方式。
vo类 public class ArealRainfallVo implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "区域编码") private String code; @ApiModelProperty(value = "雨量总和") private BigDecimal value; } Mapper类 public interface WeightBetweenObjectAndRainfallStationMapper extends BaseMapper<WeightBetweenObjectAndRainfallStation> { List<ArealRainfallVo> ListbySumList (List<PointRainfallSumVO> list); } mapper配置类 <mapper namespace="com.ndwp.jboot.bootstrap.mapper.WeightBetweenObjectAndRainfallStationMapper"> <select id="ListbySumList" resultType="com.ndwp.jboot.bootstrap.entity.vo.ArealRainfallVo"> SELECT code, SUM(CASE <foreach collection="list" item = "item"> WHEN rainfall_station_code = '${item.getCode()}' THEN weight * ${item.getValue()} </foreach> END ) AS value FROM bootstrap.weight_between_object_and_rainfall_station GROUP BY code; </select> </mapper> 服务类 public interface IWeightBetweenObjectAndRainfallStationService extends BaseService<WeightBetweenObjectAndRainfallStation> { List<ArealRainfallVo> listAreaRainfall(Date start, Date end); } 服务实现类 @Service public class WeightBetweenObjectAndRainfallStationServiceImpl extends BaseServiceImpl<WeightBetweenObjectAndRainfallStationMapper, WeightBetweenObjectAndRainfallStation> implements IWeightBetweenObjectAndRainfallStationService { @Autowired IDataHistoricRainfallService dataHistoricRainfallService; @Override public List<ArealRainfallVo> listAreaRainfall(Date start, Date end) { List<PointRainfallSumVO> pointRainfallSumVOS = dataHistoricRainfallService.listAllPointRainfallByTime(start, end); return baseMapper.ListbySumList(pointRainfallSumVOS); } } 控制台打印的sql语句能够正常运行,结合代码分析一下为何会返回四个空对象?
根据你提供的代码,我注意到你在mapper配置文件中使用了foreach循环来动态生成SQL语句中的条件部分。然而,你在foreach循环中使用了`${item.getCode()}`和`${item.getValue()}`来获取集合中每个元素的属性值,这是不正确的。
在MyBatis中,`${}`语法用于替换普通的字符串,它不会对参数进行预处理或转义。所以在你的SQL语句中,`${item.getCode()}`和`${item.getValue()}`会被直接替换为对应元素的`getCode()`和`getValue()`方法的返回值,而不是参数值。
为了修复这个问题,你可以改用`#{}`语法来将参数作为预处理参数传递给SQL语句。修改后的mapper配置文件如下所示:
```xml
<mapper namespace="com.ndwp.jboot.bootstrap.mapper.WeightBetweenObjectAndRainfallStationMapper">
<select id="ListbySumList" resultType="com.ndwp.jboot.bootstrap.entity.vo.ArealRainfallVo">
SELECT code, SUM(CASE
<foreach collection="list" item="item" separator=" ">
WHEN rainfall_station_code = #{item.code} THEN weight * #{item.value}
</foreach> END ) AS value
FROM bootstrap.weight_between_object_and_rainfall_station
GROUP BY code;
</select>
</mapper>
```
修改后重新运行代码,应该能够正确地获取到数据库中的数据并返回非空对象。