尝试使用Tomcat 7 Maven插件和CXF 2.7.8部署JAX-WS端点.作为优先选择,我不想为Spring或CXF提供任何XML配置.我看到几个博客,文章,帖子使用cxf-servlet.xml
和CXFServlet,但没有任何完全使用Java配置.查看CXFServlet源代码,它会cxf-servlet.xml在密钥下查找servlet上下文中的任何内容'config-location'.我尝试以编程方式注册端点而不是in cxf-servlet.xml,但它不起作用; 我在访问该服务时获得了404.有任何想法吗?
@Configuration
@ImportResource({ "classpath:META-INF/cxf/cxf.xml" })
public class CXFConfig {
@Autowired
Bus cxfBus;
// More code
@Bean
public Endpoint calculator() {
EndpointImpl endpoint = new EndpointImpl(cxfBus, new Calculator());
endpoint.setAddress("/CalculatorService");
return endpoint;
}
}
Run Code Online (Sandbox Code Playgroud) 我必须实现的逻辑是将所有请求记录到提供给DB的正文.
所以我决定使用:afterCompletion方法HandlerInterceptor.有传递给此方法两个参数HttpServletRequest和HttpServletResponse其他人之间.
问题是:如何获取RequestBody和ResponseBody提供的对象?
据我所知,我们可以使用@RequestBody和@ResponseBody.我可以重复使用HandlerInterceptor吗?
我想在animalSniffer插件中有一个任务依赖于所有源集中所有生产类(Java,Groovy,Scala)的编译,第二个任务依赖于所有源集中所有测试类的编译(可能是单独的test和integrationTest).
我不想依赖*classes任务,因为*classes任务应该依赖于animalSniffer任务(在编译后检测Java版本API不兼容并且可以停止构建).
在Gradle中有没有比检查AbstractCompile任务名称实例是否以"compileTest"开头更好的方法?
我在开发环境中使用嵌入式 MongoDB数据库。它在应用程序启动时设置为空。我想在设置 Spring 上下文时加载应用程序所需的初始数据。
Spring Data MongoDB 中有没有办法指向将加载到数据库中的 JSON 文件(类似于 Hibernate 中的 import.sql (hibernate.hbm2ddl.import_files) 或NoSql Unit中的 @UsingDataSet )?
要从另一个子项目添加对测试源集的简单依赖,我可以这样做:
testCompile project(':subFoo1').sourceSets.test.output
Run Code Online (Sandbox Code Playgroud)
此解决方案有效,但在许多情况下,并不打算将整个源集添加为依赖项.例如,我想只使用测试数据构建器,在这种情况下,像test-logback.xml(和常规测试)这样的文件会污染主模块中的测试类路径.
我尝试了测试JAR的想法(可以有过滤内容,但作为依赖项有问题)和一些组合eachFileRecurse,但没有运气.
我的问题.如何只添加给定源集的子集(例如,只有具有匹配**/*Builder.*模式的构建器的类)作为另一个子项目中的testCompile依赖项?
贝娄我的实际pom的一部分.已经在@Test注释中为集成测试的Testng测试分配了一个"集成"组.为了做一点测试,我没有在测试阶段排除"集成"组.
使用例如mvn verify或mvn install进行构建时,集成测试将在测试阶段执行,但不会在验证阶段或集成测试阶段执行.测试的次数仍为0.不知怎的,它们没有被提取.任何人都知道什么可能是错的?
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.1</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12.1</version>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludedGroups>unit</excludedGroups>
</configuration>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
<configuration>
<skip>false</skip>
<excludedGroups>unit</excludedGroups>
</configuration>
</execution>
</executions>
<configuration>
<skip>false</skip>
<excludedGroups>unit</excludedGroups>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
更新:添加TestNG作为故障安全插件的依赖项没有帮助
integration testng maven maven-surefire-plugin maven-failsafe-plugin
只是想知道是否有任何理由toString()明确地调用对象来打印它?
MyClass obj = new MyClass(); // Assume toString() method is overriden in this class
System.out.println(obj);
System.out.println(obj.toString());
Run Code Online (Sandbox Code Playgroud)
我显然使用第一种方法,但我的一位同事争辩说我应该放弃它obj.toString()!我觉得toString()只是多余而不使用它实际上减少了机会NPE!
我错过了什么或者有没有理由toString()明确使用?
java ×6
gradle ×2
spring ×2
cxf ×1
email ×1
groovy ×1
integration ×1
jax-ws ×1
maven ×1
mongodb ×1
spring-data ×1
spring-mvc ×1
testng ×1
tomcat ×1
tostring ×1