SpringBoot工程搭建

本文介绍如何为Eclipse安装特定版本的Spring Tool Suite (STS),包括下载历史版本STS插件的方法及步骤,适用于希望定制Eclipse开发环境的用户。

开发工具:eclipse

查看本机eclipse是否安装对应版本的STS

sts下载地址:https://spring.io/tools/sts/legacy

注意:

目前spring官网(http://spring.io/tools/sts/all)上可下载的spring插件只有:springsource-tool-suite-3.8.4(sts-3.8.4)。但这只针对指定的eclipse版本适用。

如何为自己的eclipse下载历史版本的sts呢?拼下载的url。

首先,鼠标右键可下载的sts链接,然后“复制链接地址”,把地址拷贝出来。


地址如下:http://download.springsource.com/release/TOOLS/update/3.8.4.RELEASE/e4.7/springsource-tool-suite-3.8.4.RELEASE-e4.7.0-updatesite.zip

然后点击历史版本链接,查看历史版本信息。(注意这里历史版本列表中提供的下载文件,并不能直接作为sts插件使用)

以历史版本列表中sts-3.7.2版为例。


拷贝出来的地址如下:

http://download.springsource.com/release/STS/3.7.2.RELEASE/dist/e4.5/spring-tool-suite-3.7.2.RELEASE-e4.5.1-win32-x86_64.zip

现在将两个地址进行比较和拼接:

sts-3.8.4插件下载地址:http://download.springsource.com/release/TOOLS/update/3.8.4.RELEASE/e4.7/springsource-tool-suite-3.8.4.RELEASE-e4.7.0-updatesite.zip

sts-3.7.2历史版本信息下载地址:http://download.springsource.com/release/STS/3.7.2.RELEASE/dist/e4.5/spring-tool-suite-3.7.2.RELEASE-e4.5.1-win32-x86_64.zip

拼出sts-3.7.2的插件下载地址是:http://download.springsource.com/release/TOOLS/update/3.7.2.RELEASE/e4.5/springsource-tool-suite-3.7.2.RELEASE-e4.5.1-updatesite.zip

下载文件必须要以updatesite.zip结尾。

然后eclipse中  Help-->Install New Software...



选择下载完毕的插件



等待安装。。。这个过程可能需要二三十分钟。。。



安装完成重启eclipse

注意:

安装完毕后,新建工程如果不包含如下项目,说明插件安装失败,或者jdk版本不对,检查jdk版本是否为1.8

如jdk版本不为1.8,请安装,安装jdk1.8时请注意jdk版本和eclipse版本要对应,32对应32,64对应64,否则eclipse启动会报错。


--工程创建


--视图解析

待完善。。。。。



在Spring Boot工程搭建单元测试框架,可按以下步骤操作: ### 测试类存放置 Spring Boot中单元测试类应写在`src/test/java`目录下,可以手动创建具体测试类,若使用IDEA,还能通过IDEA自动创建测试类,也可使用快捷键⇧⌘T(MAC)或者Ctrl + Shift + T(Window)来创建[^1]。 ### 编写单元测试代码示例 以下是两个不同的单元测试代码示例: #### 示例一 ```java @RunWith(SpringRunner.class) @SpringBootTest public class PracticeControllerTest { @Autowired private PracticeService practiceService; @Test public void test() { String aaa = practiceService.aaa(); System.out.println(aaa); } } ``` 此示例中,`@RunWith(SpringRunner.class)`用于指定运行测试的运行器,`@SpringBootTest`表示这是一个Spring Boot测试。通过`@Autowired`注入需要测试的`PracticeService`类,然后在`test`方法中调用其方法进行测试[^2]。 #### 示例二 ```java @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class AtrributeDataMapperTest { private static final Logger logger = LogManager.getLogger(AtrributeDataMapperTest.class); @Autowired private AtrributeDataMapper mappper; @Test public void testGetColumnValues_Level3_Cable() { Integer instanceId = 2230; String tableName = "t_cable"; Integer level = 3; String field = "Length"; List<Object> data = mappper.getColumnValues(instanceId, tableName, level, field); data.forEach(System.out::println); } } ``` 该示例同样使用`@RunWith(SpringRunner.class)`和`@SpringBootTest`,不同的是`@SpringBootTest`的`classes`属性指定了Spring Boot的启动类的`class`(如`Application.class`)。若不加`classes`属性,当前测试类必须在启动类所在的包或其子包中,否则会在运行时抛出异常。通过`@Autowired`注入需要测试的`AtrributeDataMapper`类,在`testGetColumnValues_Level3_Cable`方法中调用其方法进行测试[^3]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值