我的应用程序有很多EJB.当前定制的Logger实现创建了一个这样的记录器;
private static Logger logger = Logger.getInstance("SERVICE_NAME");
,日志记录将进入文件;
(路径)/SERVICE_NAME/SERVICE_NAME.log
我想用logback复制这种行为,但是在logback.xml配置中抓住'logger'名称时遇到了麻烦.它可以在log encoder.pattern中看到,即"%d%-5level%logger {35} - %msg%n".
有什么想法我怎么能把它变成属性/变量然后在元素中使用它?
我们正在将我们的Hibernate(5.0.2)代码迁移到Java 8,它还涉及从转换java.util.Date到java.time.LocalDate(以解决与Java 7中的日期处理相关的问题).我遇到的一个问题是Hibernate如何处理我们用作"零日期"的特殊值,即0001-01-01.
该属性声明如下:
@NotNull
@Column(name = "START_DATE", nullable = false)
private LocalDate startDate;
Run Code Online (Sandbox Code Playgroud)
该值存储在数据库中0001-01-01,但是当它被Hibernate加载时,它突然转向0000-12-29.我假设发生这种情况是因为Hibernate默认使用格里高利历,并且因为这个日期是在它引入之前,所以使用了一些转换.
有没有办法配置Hibernate来禁用这种行为(除了实现一个特殊的属性编写器)?
我在这里有点没有主意。我想要一件非常简单的事情:能够GtkListBox以编程方式选择给定行,然后滚动列表框(包含在 aScrolledWindow和 a中Viewport)。
选择一行很简单(我的代码是 Go & gotk3,但这并不那么重要):
listBox.SelectRow(row)
Run Code Online (Sandbox Code Playgroud)
但事实证明,滚动到该行是一个真正的挑战。无论我尝试什么,我都失败了:
gtk_widget_translate_coordinates(),但它对任何行返回 -1ScrolledWindow但我不知道如何做到这一点。更新:我已经尝试过这里建议的内容:Manually roll to a child in a Gtk.ScrolledWindow,但它不起作用,因为仍然没有发生滚动:
listbox.SelectRow(rowToSelect)
listbox.SetFocusVAdjustment(listbox.GetAdjustment())
if rowToSelect != nil {
rowToSelect.GrabFocus()
}
Run Code Online (Sandbox Code Playgroud)
我也使用下面的代码对 的孩子进行了相同的尝试rowToSelect,但无济于事:
if c, err := rowToSelect.GetChild(); err == nil {
c.GrabFocus()
}
Run Code Online (Sandbox Code Playgroud) 运行 Karma 测试时,我收到很多错误(实际上是警告),如下所示:
ERROR: 'NG0304: 'fa-icon' is not a known element:
1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.'
Run Code Online (Sandbox Code Playgroud)
现在,一旦您知道哪个组件抱怨未知元素,这个问题就很容易解决。问题是应用程序有几十个这样的问题,而 Karma 的输出没有提供任何关于问题出现的线索。
如何找出导致错误的组件,而不需要有选择地针对每个组件运行测试?
我正在为 Spring MVC 4.2.x REST 控制器编写单元测试,并且对 Jackson (2.6.x) 序列化的日期有问题。运行应用程序时,日期 ( java.util.Date) 默认以默认格式序列化yyyy-MM-dd(无需额外配置),这就是我想要的。
然而,在测试期间,由于未知原因,日期被序列化为时间戳。
这是测试类的一些示例代码:
public class OrderControllerTest {
@Mock
private OrderService service;
@InjectMocks
private OrderController controller;
private MockMvc mockMvc;
private List<Order> orders = new ArrayList<>();
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mockMvc = MockMvcBuilders.standaloneSetup(controller).build();
// Initialize dummy order list
orders.add(...);
orders.add(...);
orders.add(...);
}
@Test
public void list() throws Exception {
// Stub the service find method
when(service.find(asOfDate, null)).thenReturn(orders);
// Run the controller and check the result
MvcResult …Run Code Online (Sandbox Code Playgroud) 我们开发了一个Web应用程序,它在后端使用Java,在Angular中使用UI,使用Maven作为构建系统.
我一直在尝试使用Protractor设置自动集成测试,并且在加载Googling/StackOverflowing之后仍然无法弄清楚如何实现端到端配置.
我已经尝试使用frontend-maven-plugin来处理Node.js和NPM安装,但由于我们是在公司防火墙后面,所以似乎无法直接下载任何东西.它可以从我们的Artifactory下载Node但是在NPM下载时失败了(我不明白为什么它甚至下载它因为它是Node包的一部分).无论如何,我放弃了这个想法,并决定使用本地安装的Node.
启动/停止用于e2e测试的Tomcat实例可以很好地处理
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>${tomcat.manager.url}</url>
<path>/</path>
<server>Tomcat</server>
</configuration>
<executions>
<!-- Starting Tomcat -->
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<!-- Fork the process, otherwise the build will be blocked by the running Tomcat -->
<fork>true</fork>
<port>${tomcat.port}</port>
<systemProperties>
<!-- We want to use the 'e2e' profile for integration testing -->
<spring.profiles.active>e2e</spring.profiles.active>
</systemProperties>
</configuration>
</execution>
<!-- Stopping Tomcat -->
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我设法启动WebDriver,但问题是它阻止了任何进一步的执行:
<plugin>
<groupId>org.codehaus.mojo</groupId> …Run Code Online (Sandbox Code Playgroud) 对于我们的 end-2-end 测试,我们需要执行以下逻辑流程:
pre-integration-test)pre-integration-test)pre-integration-test)pre-integration-test)integration-test使用 Protractor在 Tomcat ( ) 中运行 Web 应用程序post-integration-test)post-integration-test)对于运行 SQLsql-maven-plugin使用,但是此流程不适合常规 POM 布局:
pre-integration-test两次,之前和之后的liquibase-maven-pluginpre-integration-test,但是它必须在during之后运行post-integration-test,以便在 Tomcat 关闭后删除 DB 模式。据我从Maven docs …
我无法开始使用spring-boot-starter-data-jpa.我按照本指南创建了一个简单的Spring Boot应用程序,但是使用了Hibernate和相关的配置.
的build.gradle:
dependencies {
// Spring stuff
compile 'org.springframework.boot:spring-boot-starter-data-jpa:1.5.1.RELEASE'
compile 'org.springframework.data:spring-data-jpa'
compile 'org.springframework:spring-webmvc'
// Jackson
compile 'com.fasterxml.jackson.core:jackson-databind:+'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:+'
// Postgres
compile 'org.postgresql:postgresql:+'
// Hibernate
compile 'org.hibernate:hibernate-core:5.2.8.Final'
}
Run Code Online (Sandbox Code Playgroud)
每当我尝试运行应用程序时,我最终会得到以下结果:
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-02-24 16:20:27.710 ERROR 1070 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jpaContext': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying …Run Code Online (Sandbox Code Playgroud) java ×3
hibernate ×2
maven ×2
angular ×1
angularjs ×1
datetime ×1
go ×1
gtk ×1
gtk3 ×1
java-8 ×1
jpa ×1
json ×1
karma-runner ×1
liquibase ×1
logback ×1
mockito ×1
node.js ×1
protractor ×1
selenium ×1
spring ×1
spring-boot ×1
spring-mvc ×1
tomcat ×1
unit-testing ×1