我知道这个问题不止一次被问到.但我不能让maven使用failsafe-plugin运行我的集成测试.
当我执行mvn failsafe:integration-test failsafe:verify它时,运行我的集成测试.但是当我执行mvn verify我的集成测试时没有运行.
的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bahadirakin</groupId>
<artifactId>integration-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>integration-tests</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
集成测试
package com.bahadirakin.integration;
import org.junit.Assert;
import org.junit.Test;
public class ServiceIT {
@Test
public void testFail() throws Exception {
Assert.fail();
}
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我希望它会失败.
Maven版本
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; …Run Code Online (Sandbox Code Playgroud) 我刚刚将项目的hibernate版本升级到5.0.0.FINAL.但我意识到这一点,我收到了这个警告.我想摆脱它.我不知道它是否会影响我的申请.
2015-08-24 14:29:22.235 WARN --- [ main] org.hibernate.orm.deprecation : HHH90000003: Use of DOM4J entity-mode is considered deprecated
Run Code Online (Sandbox Code Playgroud)
由于我从未明确使用实体模式,因此我在网上搜索但几乎没有关于它的信息.这是EntityMode枚举.因为,没有DOM4J模式,我怀疑如果我继续在5.0.0版本中使用hibernate,我可能会在生产中出错.
我也在使用hibernate的envers.如果我禁用envers,警告也会消失.我正在使用spring和hibernate以及envers.这是他们的版本.
<spring.version>4.2.0.RELEASE</spring.version>
<hibernate.version>5.0.0.Final</hibernate.version>
<hibernate.envers.version>5.0.0.Final</hibernate.envers.version>
<hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version>
<project.java.version>1.8</project.java.version>
Run Code Online (Sandbox Code Playgroud)
这是我的hibernate-jpa配置.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<bean id="commonsEntityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="commonDataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.ejb.interceptor">com.examples.dao.utils.AbstractEntityInterceptor</prop>
<!--<prop key="hibernate.listeners.envers.autoRegister">false</prop>-->
<prop key="hibernate.implicit_naming_strategy">org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl</prop>
<prop key="hibernate.physical_naming_strategy">org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.showSql">${hibernate.showSql}</prop>
<prop key="hibernate.formatSql">${hibernate.formatSql}</prop>
<prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
<prop key="hibernate.max_fetch_depth">${hibernate.max_fetch_depth}</prop> …Run Code Online (Sandbox Code Playgroud) 我有一个多线程的应用程序.我希望只有一个线程执行我的函数,而其他线程在执行函数时传递它.我怎样才能做到这一点?
我的方法是这样的:
public void setOutput(int value)
{
try
{
GPOs gpos = reader.Config.GPO;
gpos[1].PortState = GPOs.GPO_PORT_STATE.TRUE;
gpos[2].PortState = GPOs.GPO_PORT_STATE.TRUE;
Thread.Sleep(WAIT);
gpos[1].PortState = GPOs.GPO_PORT_STATE.FALSE;
gpos[2].PortState = GPOs.GPO_PORT_STATE.FALSE;
}
catch (Exception ex)
{
logger.Error("An Exception occure while setting GPO to " + value + " " + ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Colab 笔记本学习 Tensorflow入门教程。
成功之后,我决定尝试一下保存模型。我试着保存它并且它起作用了。(感谢这个答案)
# Saving Model to Drive
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
# Authenticate and create the PyDrive
client.auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
# Save Keras Model or weights on google drive
model.save('getting-started-wtih-tf.h5')
model_file = drive.CreateFile({'title' : 'getting-started-wtih-tf.h5'})
model_file.SetContentFile('getting-started-wtih-tf.h5')
model_file.Upload()
# download to google drive
drive.CreateFile({'id': model_file.get('id')})
Run Code Online (Sandbox Code Playgroud)
但几周后,它开始因这个异常而失败。
NotImplementedErrorTraceback (most recent …Run Code Online (Sandbox Code Playgroud)