POM文件api
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.0</version> </dependency> <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.25</version> </dependency> <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency> <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.2.0</version> <scope>test</scope> </dependency>
在pom中添加上面的全部依賴,不少教程裏都只說添加lombok依賴就好了,其實否則。總共還須要slf4j以及它的實現,這裏我選擇了logback,其餘的實現也是能夠的。除此以外,還須要安裝一個lombok插件,只針對IDEA,其餘的IDE我不瞭解,也不知道具體需不須要這個插件。
下載到本地後,在IDEA中的seting->Plugins中,選擇單元測試
找到下載的zip包,而後安裝以後就把全部的準備工做作完了。下面能夠寫個單元測試類測試一下了。測試
單元測試類
spa
@Slf4j class LogTest { @Test void testLog() { String testInfo = "Free flying flowers are like dreams"; log.info("The test info is :{}", testInfo); } }
運行,結果如圖:.net
原文:https://blog.csdn.net/cslucifer/article/details/80953400 插件