在添加PMD的自定义规则集时,maven产生错误- net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource rulesets/comments.xml.Make sure the resource is a valid file or URL or is on the CLASSPATH。
对于其他规则集,例如基本规则,命名规则等,它没有给出任何错误。但是当我添加新规则集时,它会产生错误。我也尝试过,<rule ref="rulesets/java/comments.xml/CommentRequired"/>但它也给出了同样的错误。在pmd-5.0.2.jar文件中已经可以使用comments.xml。
我的POM.xml
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>pmd</groupId>
<artifactId>pmd</artifactId>
<version>5.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/site/
</outputDirectory>
<reportOutputDirectory>${project.reporting.outputDirectory}/site/
</reportOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<targetjdk>1.6</targetjdk>
<skip>fasle</skip>
<failOnViolation>false</failOnViolation>
<failurePriority>4</failurePriority>
<verbose>true</verbose>
<rulesets>
<ruleset>src/main/resources/rulesets/MyRuleSet.xml</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals> …Run Code Online (Sandbox Code Playgroud) 我正在使用带有Spring AOP的slf4j进行日志记录和异常目的.在某些类中有一些方法形成了一个方法链接.我能够记录第一个方法的入口和出口点,但是当这个方法调用另一个方法时,AOP只记录第一个方法的入口和出口点.我想记录每个方法的入口和退出点,@Around这里使用注释是Pseudo代码来解释我想要的是
package com.sample;
public class Test implements T{
@Override
public void show() {
System.out.println("Test.show()");
test();
}
void Test(){
//Want to log entry and exit point of this method whenever this method called by any other method
//The method may belongs to same class or different package's different class
}
Run Code Online (Sandbox Code Playgroud)
spring.xml 是这样的
<bean id="exceptionAspect" class="com.sample.ExceptionAspect"/>
<bean id="test" class="com.sample.Test"/>
Run Code Online (Sandbox Code Playgroud)
我的Advise class样子
@Aspect
public class LoggingAspect {
@Around(value="execution (* com.sample.*.*(..))||"+
"execution(* some other package.*.*(..))")
public void logAround(ProceedingJoinPoint joinPoint) …Run Code Online (Sandbox Code Playgroud) 我正在使用protocol buffer和创建一个示例程序protobuf-java-format。我的原型文件是
package com.sample;
option java_package = "com.sample";
option java_outer_classname = "PersonProtos";
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
}
Run Code Online (Sandbox Code Playgroud)
我的示例程序是
package com.sample;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import com.google.protobuf.Message;
import com.googlecode.protobuf.format.XmlFormat;
import com.sample.PersonProtos.Person;
/**
* This class generate XML out put from Object and vice-versa
*
* @author mcapatna
*
*/
public class Demo
{
public static void main(String[] args) throws …Run Code Online (Sandbox Code Playgroud) 我在一个文件中有多行。我想在带有附加后缀空格或制表符并以,.
例如,文件的示例内容如下所示:
Deepak Kumar
Deepak The powerhouse
Deepak mcapatna
Run Code Online (Sandbox Code Playgroud)
我想要的输出文件是
Deepak Kumar kumar,
Deepak The powerhouse powerhouse,
Deepak mcapatna mcapatna,
Run Code Online (Sandbox Code Playgroud)