首页 文章 精选 留言 我的

精选列表

搜索[java],共10000篇文章
优秀的个人博客,低调大师

Java JUnit框架里@Category注解的工作原理

Suppose you have a large number of unit test cases and you don’t want them to be executed all at the same time during Maven build. You can simply achieve it via annotation @Category. (1) Create empty class FastTests and SlowTests.(2) In your test case class, categorize your test method using @Category annotation: (3) Append the following code to your pom.xml: <profiles> <profile> <id>SlowTests</id> <properties> <testcase.groups>com.sap.SlowTests</testcase.groups> </properties> </profile> <profile> <id>FastTests</id> <properties> <testcase.groups>com.sap.FastTests</testcase.groups> </properties> </profile> </profiles> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.13</version> <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit47</artifactId> <version>2.13</version> </dependency> </dependencies> <configuration> <groups>${testcase.groups}</groups> </configuration> </plugin> </plugins> </build> (4) In my project, by default all 7 test methods will be executed during Maven build: Suppose you only want to execute unit test belonging to category “SlowTests”, use the following command line: Since now I only marked one method with annotation SlowTests, only one test method is executed: If you would like to execute all unit tests EXCEPT @SlowTests, simply add another profile in pom.xml: <profile> <id>NonSlowTests</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <excludedGroups>com.sap.SlowTests</excludedGroups> </configuration> </plugin> </plugins> </build> </profile> Before test, in order to prove that Slow method is NOT really executed, I add a system.out.println in each method: Use command line: mvn test -P NonSlowTestsFrom console output, I can ensure that the method with @Category(SlowTests.class) is NOT executed at all. 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

优秀的个人博客,低调大师

Java工程师如何写出高效代码?

1.常量&变量 1.1.直接赋值常量值,禁止声明新对象 直接赋值常量值,只是创建了一个对象引用,而这个对象引用指向常量值。 反例:Long i = new Long(1L);String s = new String("abc"); 正例:Long i = 1L;String s = "abc"; 1.2.当成员变量值无需改变时,尽量定义为静态常量 在类的每个对象实例中,每个成员变量都有一份副本,而成员静态常量只有一份实例。 反例:public class HttpConnection { private final long timeout = 5L; ... } 正例:public class HttpConnection { private static final long TIMEOUT = 5L; ... } 1.3.尽量使用基本数据类

优秀的个人博客,低调大师

spider-flow 0.5.0 发布,Java 开源爬虫平台

spider-flow 是一个无需写代码的爬虫平台,通过定义流程的方式制定爬虫。 本次更新内容如下: 新增注释节点 新增字符串反转义函数 新增属性窗口切换靠右/靠底 新增消息通知功能(任务启动通知、任务停止通知) 新增自动重试功能 新增自动去重功能 新增流程历史版本记录 新增rest服务异步启动、查看状态、停止接口 新增长任务模式 新增输出节点可选编码格式 新增函数elementsVar.htmls、outerHtmls、texts、attrs、ownTexts、wholeTexts等方法 修复全局参数回显不出值的BUG 修复删除任务时未停止任务的BUG 修复日志下载内容为空的BUG 修复输出csv文件被锁定的问题 优化编辑器可跨页面/tab复制粘贴节点 优化循环,增加开始位置、结束位置、循环次数或集合,循环下标等 优化页面样式 优化文档 ocr插件 优化配置,单独提取出配置列表(与数据源类似) mailbox插件 优化配置,单独提取出配置列表(与数据源类似) 产品规划 从v0.6.0版本起前端将改用vue重构,有兴趣的小伙伴可以联系我~ 截图 Github https://github.com/javamxd/spider-flow

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册