SpringBoot项目实战开发(一)技术选型

前言:springboot项目是当前流行的java web项目,本篇主要针对项目的技术选型进行说明。此经验在实战中应用和检验过,在生产环境(centos7)下相当稳定,且扩展性强,比如后期扩展redis,mongodb等缓存技术,以及spring相关技术都很简单。

技术选型最重要的是:开发代价(包括学习,使用和代码阅读代价),生产环境下的稳定性

springboot版本:2.2.5.RELEASE

随着springboot版本的升级,就实战中来看,1.x,2.0~2.1,2.2以上版本有较大区别,2.2之后的版本并不会影响新技术的兼容,同时能更好的兼容springcloud的新版本的各种特性及插件。--springboot2.2能支撑springcloud的Hoxton.SR3,同时对springAdmin(2.2.1版本,支持中文国际化)也有很好支持。

容器:undertow

boot自带的内置容器是tomcat,但是经本地使用测试和生产环境长期观察,并没有undertow的性能好,关于两个容器的性能比较,相信可以找到很多资料,这里只以实践经验来说,undertow更优于tomcat。

模板引擎:Beetle 1.2.14.RELEASE (文档传送门)

boot自带的是thymeleaf,这种技术在国外很流行,但是国内更流行的是jsp,jsp属于脚本语言,在springMvc时代很流行且应用极好,但是在boot这种轻量级架构中使用太重,所以犹豫再三还是选择了beetle,在很早开发的时候接触过framemarker,对于模板引擎是又爱又恨,爱的是性能很棒,恨的是可读性极差,那模板文件乱糟糟的,不是自己开发的不花点功夫真看不懂,beetle既有framemarker的性能,同时拥有html的可读性,还兼容了jsp的el表达式.超赞.

数据持久化:BeetSql 1.2.14.RELEASE (文档传送门)

数据持久化市面上有两套核心:ORM(hibernate,JPA),jdbc(mybatis),当然都可以互通,但显式使用还是很麻烦,mybatis pubs版本在mybatis的基础上增强了ORM,但是还是没有BeetSql这种在设计之初就照顾到双方的技术好用.

json工具:fastjson 1.2.73

关于json工具,boot自带的是jackjson,关于哪种好,众说纷纭,就使用而言,都差不多,因为只关注性能的底线,序列化的能力和开发是否方便.

pom文件如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ds</groupId>
  <artifactId>sboot-demo</artifactId>	<!-- 项目名称 -->
  <version>0.0.1</version> 					<!-- 打包版本 -->
  <packaging>jar</packaging>			<!-- 打包方式 -->
  <!-- springboot版本,引入spring的包不用指定版本,会以此版本兼容模式引入 -->
  <parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.2.5.RELEASE</version>
		<relativePath />
	</parent>
	<!--dependencies引入包区域  -->
	<dependencies>
		<!-- 构建web应用,剔除内嵌的tomcat -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-tomcat</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<!-- 使用undertow高性能web服务器,取代tomcat -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-undertow</artifactId>
		</dependency>
		<!-- 集成beetl,包含了beetle和beetlsql -->
		<dependency>
			<groupId>com.ibeetl</groupId>
			<artifactId>beetl-framework-starter</artifactId>
			<version>1.2.14.RELEASE</version>
		</dependency>
		<!-- 自动装配数据源,操作数据库 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>com.zaxxer</groupId>
			<artifactId>HikariCP</artifactId>
		</dependency>
		<!-- 此处可不配置版本,但是需要注意自己mysql的版本,5.5以下最好配置版本,
		最新版本驱动,需要mysql在5.7及以上,同时配置文件中的驱动路径也有变化-->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>5.1.37</version>
		</dependency>
		<!-- 简便操作json -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.2.73</version>
		</dependency>
		<!--apache工具,有很多工具很好用,比如 StringUutils  -->
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</dependency>
		<!-- 简便使用实体类getset和构造方法;slf4j输出日志 -->
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<scope>provided</scope>
		</dependency>
		<!-- test测试 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<!-- devtool热部署 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional>
			<scope>true</scope>
		</dependency>
	</dependencies>
	<!-- build 顾名思义,是工程创建配置 -->
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<target>1.8</target>
					<source>1.8</source>
					<encoding>UTF-8</encoding>
					<compilerArgs>
						<arg>-parameters</arg>
					</compilerArgs>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<fork>true</fork>
					<!--这里只打包程序文件,不打包依赖jar,可对最终生成的jar包进行瘦身 -->
					<layout>ZIP</layout>
					<includes>
						<include>
							<groupId>com.ds</groupId>
							<artifactId>sboot-demo</artifactId>
						</include>
					</includes>
					<!--若想获得依赖jar,可把此段程序注释再生成即可 -->
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
SpringBoot项目实战笔记可以按照以下步骤进行: 1. 首先,你可以通过观看B站上的教程视频来学习SpringBoot项目实战。在视频中,你可以学习到如何使用SpringBoot、MyBatis和MySQL创建一个电脑商城项目。 2. 确保你的SpringBoot项目能够成功启动。找到被@SpringBootApplication注解修饰的入口启动类,并运行该类。如果你能够观察到图形化的界面,那么说明你的项目成功启动了。 3. 如果你还没有创建SpringBoot项目,你可以使用Spring Initializr来初始化一个新的项目。Spring Initializr是一个Web应用程序,可以为你生成Spring Boot项目的基本结构。你可以选择使用Maven或Gradle作为构建工具,并添加适合你的项目的依赖。然后,你只需要编写应用程序的代码即可。 希望以上信息对你有帮助!如果还有其他问题,请随时提问。123 #### 引用[.reference_title] - *1* *2* [SpringBoot项目实战笔记:电脑商城项目实战SpringBoot+MyBatis+MySQL)](https://blog.csdn.net/weixin_44260350/article/details/127746667)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *3* [《SpringBoot实战》读书笔记](https://blog.csdn.net/sanhewuyang/article/details/104494202)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冬山兄

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值