工作中几个常用的方法

比如正则表达式的使用等


public String getGeneratorUUID() {
return UUID.randomUUID().toString().replaceAll(SEPARATOR_LINE, StringUtils.EMPTY);
}

public String getParseNodeId(String nodeId) throws InstallResourceMgmtServiceException {
String id = nodeId;
if (null != nodeId && !StringUtils.isNumeric(nodeId)) {
String regEx = "(_[\\d]+)";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(nodeId);
if (m.find()) {
id = m.group(1).split(SEPARATOR_UNDER_LINE)[1];
} else {
throw new InstallResourceMgmtServiceException(SystemErrorCode.E10204004012, String.format(PARSE_NODE_ID_ERROR, new Object[] { id }));
}
}
return id;
}

public String getParseNodeType(String node) throws InstallResourceMgmtServiceException {
String type = node;
String regEx = "(^([a-zA-Z]+_[a-zA-Z]+|[a-zA-Z]+))";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(node);
if (m.find()) {
type = m.group(1);
} else {
throw new InstallResourceMgmtServiceException(SystemErrorCode.E10204004013, String.format(PARSE_NODE_TYPE_ERROR, new Object[] { node }));
}
return type;
}



字符串的格式化


protected static final String NOT_FOUND_DATA = "Not found %s.";

throw new InstallResourceMgmtServiceException(SystemErrorCode.E10204004008, String.format(NOT_FOUND_DATA, new Object[] { "neResource" }));



maven构建时复制依赖的jar及同时加入到classpath

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix></classpathPrefix>
<mainClass>hk.com.hgc.fn.is.customer.migration.client.CTMDataMigrationApp</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值