我在Maven有一个声纳配置文件.除代码覆盖率指标外,一切正常.我想让Sonar只为代码覆盖率指标忽略一些类.我有以下个人资料:
<profile>
<id>sonar</id>
<properties>
<sonar.exclusions>**/beans/jaxb/**</sonar.exclusions>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
<exclude>**/*Suite*.java</exclude>
<exclude>**/*RemoteTest.java</exclude>
<exclude>**/*SpringTest.java</exclude>
<exclude>**/*CamelTest.java</exclude>
<exclude>**/*FunctionalTest.java</exclude>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*DaoBeanTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
请帮忙.我试着添加类似的东西
<exclude>com/qwerty/dw/publisher/Main.class</exclude>
Run Code Online (Sandbox Code Playgroud)
但它没有帮助
UPDATE
我有一个正确的Cobertura配置文件.我试图将它添加到Sonar配置文件中,但我仍然有53%而不是Cobertura配置文件中的95%
<profile>
<id>sonar</id>
<properties>
<sonar.exclusions>**/beans/jaxb/**</sonar.exclusions>
<sonar.core.codeCoveragePlugin>cobertura</sonar.core.codeCoveragePlugin>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
<exclude>**/*Suite*.java</exclude>
<exclude>**/*RemoteTest.java</exclude>
<exclude>**/*SpringTest.java</exclude>
<exclude>**/*CamelTest.java</exclude>
<exclude>**/*FunctionalTest.java</exclude>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*DaoBeanTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.maven.plugin.version}</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/qwerty/dw/dao/*</exclude>
<exclude>com/qwerty/dw/domain/*</exclude>
<exclude>com/qwerty/dw/beans/**/*</exclude>
<exclude>com/qwerty/dw/daemon/exception/*</exclude>
<exclude>com/qwerty/dw/daemon/Main.class</exclude>
<exclude>com/qwerty/dw/sink/Main.class</exclude>
<exclude>com/qwerty/dw/publisher/Main.class</exclude>
<exclude>com/qwerty/dw/publisher/dao/*</exclude>
<exclude>com/qwerty/dw/publisher/domain/*</exclude>
</excludes>
</instrumentation>
<formats>
<format>html</format>
</formats>
<aggregate>true</aggregate> …Run Code Online (Sandbox Code Playgroud) 我正在使用spring-data的存储库 - 非常方便,但我遇到了一个问题.我可以轻松更新整个实体,但我相信当我只需要更新一个字段时,这是毫无意义的:
@Entity
@Table(schema = "processors", name = "ear_attachment")
public class EARAttachment {
private Long id;
private String originalName;
private String uniqueName;//yyyy-mm-dd-GUID-originalName
private long size;
private EARAttachmentStatus status;
Run Code Online (Sandbox Code Playgroud)
更新我只是调用方法保存.在日志中我看到了跟随:
batching 1 statements: 1: update processors.ear_attachment set message_id=100,
original_name='40022530424.dat',
size=506,
status=2,
unique_name='2014-12-16-8cf74a74-e7f3-40d8-a1fb-393c2a806847-40022530424.dat'
where id=1
Run Code Online (Sandbox Code Playgroud)
我想看到这样的事情:
batching 1 statements: 1: update processors.ear_attachment set status=2 where id=1
Run Code Online (Sandbox Code Playgroud)
Spring的存储库有很多工具可以使用名称约定来选择一些东西,也许像updateForStatus(int status)这样的更新有类似的东西;
我有java 1.6,maven 2,activeMQ 5.5和testng功能测试.当我在Idea中启动它然后确定,但是当我尝试使用maven从控制台启动它们然后在尝试通过activeMQ发送消息后进程暂停,并且在一段时间后崩溃并在日志中出现以下错误:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006d92f7a6, pid=5716, tid=7000
#
# JRE version: 6.0_27-b07
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.2-b06 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# V [jvm.dll+0x9f7a6]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
--------------- T H R E A D ---------------
Current thread (0x00000000072b6000): JavaThread "ActiveMQ Transport: …Run Code Online (Sandbox Code Playgroud) 我需要扩展名最简单的过滤器:fe文件20120523.173227.CustomerMaster05092012.QWERTY.xml route:
<from uri="file://{{fdr.folder.working.url}}&include=*.xml"/>
Run Code Online (Sandbox Code Playgroud)
不起作用:
在索引0附近悬挂元字符'*'
WARN - file://root_folder/working/) [FileConsumer] Consumer Consumer[file://root_folder/working/?delay=1000&delete=true&idempotent=false&include=*.xml&initialDelay=1000&readLock=changed] failed polling endpoint: Endpoint[file://root_folder/working/?delay=1000&delete=true&idempotent=false&include=*.xml&initialDelay=1000&readLock=changed]. Will try again at next poll. Caused by: [java.util.regex.PatternSyntaxException - Dangling meta character '*' near index 0
*.xml
^]
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*.xml
^
at java.util.regex.Pattern.error(Pattern.java:1713)
at java.util.regex.Pattern.sequence(Pattern.java:1878)
at java.util.regex.Pattern.expr(Pattern.java:1752)
at java.util.regex.Pattern.compile(Pattern.java:1460)
at java.util.regex.Pattern.<init>(Pattern.java:1133)
at java.util.regex.Pattern.compile(Pattern.java:823)
at java.util.regex.Pattern.matches(Pattern.java:928)
at java.lang.String.matches(String.java:2090)
at org.apache.camel.component.file.GenericFileConsumer.isMatched(GenericFileConsumer.java:458)
at org.apache.camel.component.file.GenericFileConsumer.isValidFile(GenericFileConsumer.java:395)
at org.apache.camel.component.file.FileConsumer.pollDirectory(FileConsumer.java:94)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:107)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at …Run Code Online (Sandbox Code Playgroud) 我有简单的类,但有匿名代码块.我需要用测试来覆盖这个课程.
public class CleanerTask {
private final Logger log = LoggerFactory.getLogger(getClass());
DataWarehouseMessageDao dwMessageDao;
int cleanerDelay = 0;
TransactionTemplate template;
public CleanerTask(DataWarehouseMessageDao dwMessageDao, int cleanerDelay, TransactionTemplate template) {
this.dwMessageDao = dwMessageDao;
this.cleanerDelay = cleanerDelay;
this.template = template;
}
public void clean() {
log.info("Cleaner started");
final Date olderThan = new Date();
olderThan.setDate(olderThan.getDate() + cleanerDelay);
template.execute(new TransactionCallback<Date>() {
@Override
public Date doInTransaction(TransactionStatus transactionStatus) {
dwMessageDao.deleteAllByStatusAndDate(DataWarehouseMessageStatus.SAVED.getValue(), olderThan);
return olderThan;
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
并测试:
@RunWith(MockitoJUnitRunner.class)
public class CleanerTaskTest {
final static int CLEANER_DELAY = …Run Code Online (Sandbox Code Playgroud) 我有以下xsd:
<xs:simpleType name="resultcode">
<xs:restriction base="xs:integer">
<xs:enumeration value="0" id="Approved_no_error">
<xs:annotation>
<xs:appinfo>
<jxb:typesafeEnumMember name="Approved_no_error"/>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
Run Code Online (Sandbox Code Playgroud)
JAX-B什么都不做,没有错误,没有警告只是不生成这个类.如果改变基数xs:integer,xs:string则可以.但我需要完整的整数值.
我用maven生成类:
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>AuthGateway</id>
<goals>
<goal>xjc</goal>
</goals>
Run Code Online (Sandbox Code Playgroud)
问题2. JAX-B和IDE(IDEA)不允许id attrribute中的空格.为什么?
<xs:enumeration value="0" id="Approved_no_error">- 好的
<xs:enumeration value="0" id="Approved no error">- 不行
这是正确的行为吗?
我有maven 3,cobertura maven插件2.51和一些classe.我需要知道我班级的考试报道.但我不想测试setter/getters.所以我只想忽略它们.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<check>
<haltOnFailure>false</haltOnFailure>
<lineRate>55</lineRate>
<branchRate>60</branchRate>
<packageLineRate>60</packageLineRate>
<packageBranchRate>60</packageBranchRate>
<totalLineRate>60</totalLineRate>
<totalBranchRate>60</totalBranchRate>
</check>
<instrumentation>
<excludes>
<exclude>com/FileCopier*.*</exclude>
<exclude>com/FileCopierWithCamel*.*</exclude>
<exclude>com/Main*.*</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
<goal>cobertura</goal>
<goal>check</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然后我添加以下ignore块
<ignores>
<!-- Ignore all setter and getter methods in your classes -->
<ignore>com.*.set*</ignore>
<ignore>com.*.get*</ignore>
<ignore>com.MyClass.getName</ignore>
</ignores>
Run Code Online (Sandbox Code Playgroud)
但似乎它不起作用.
我找到了这个链接:http: //jira.codehaus.org/browse/MCOBERTURA-52 看起来这个问题大约是5岁.我的问题有什么解决方案吗?
使用:hibernate 3.6.10,maven 2,postgres 9。我有必须工作的代码,但它没有。在我使用 hibernate 3.6.2 并得到非常沮丧的错误之前:java.lang.ClassCastException: org.hibernate.action.DelayedPostInsertIdentifier cannot be cast to java.lang.Long
但是在更新到 3.6.10 之后错误变得更加合理:javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity传递给持久化
代码是一个标准的领域模型:
实体:
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
@Entity
@Table(schema = "simulators", name = "mySimulator_card")
public class MySimulatorCard {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "account_number", unique = true, nullable = false)
private String accountNumber;
Run Code Online (Sandbox Code Playgroud)
等等...
道:
public abstract class AbstractDao<E, PK extends Serializable> implements Dao<E, PK> {
private EntityManager entityManager;
public EntityManager getEntityManager() {
return entityManager;
} …Run Code Online (Sandbox Code Playgroud) 由于我们的主战争文件大小约为40 Mb(并且它不是整个项目中的单个war文件),因此提出了这个问题.并且所有其他jar文件大约是20 Mb,因此如果我们不会部署战争,每个版本占用的空间要大3倍.
那么也许有一个选项可以不部署整个war文件但只有资源,那么部署团队可以从Nexus构建它?如果我跳过部署我们构建war文件的模块,那么部署团队无法在不访问源代码的情况下构建它.
在公司本地存储库中部署war文件是否常见?