如何将手机号码分为国家代码,区号和本地号码?拆分后例如+919567123456
国家代码= 91
区号= 9567
当地号码= 123456
我想使用TestNG的与神火插件的Maven的.我们的想法是用一个组标记一些测试integrationTest并运行插件两次:对于test排除组integrationTest的目标和仅integration-test包括组的目标integrationTest.
我找到了一些用于为两个目标运行插件的材料,但是它可以工作,但是第二次运行的组不起作用(没有执行测试).
这是我的构建元素中的插件配置pom.xml:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>integrationTest</excludedGroups>
<reportFormat>brief</reportFormat>
<trimStackTrace>true</trimStackTrace>
<useFile>false</useFile>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<groups>integrationTest</groups>
<excludedGroups/>
<reportsDirectory>${project.build.directory}/surefire-reports/integration</reportsDirectory>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
任何的想法?mvn integration-test按预期运行所有单元测试(不包括组integrationTest),但第二次测试运行只写:
运行TestSuite
测试运行:0,失败:0,错误:0,跳过:0,已过去时间:0.562秒
结果mvn test如预期,测试运行和组integrationTest被忽略.
我在tomcat 6下部署的apring webapp中的日志设置有问题.
webapp使用commons-logging api,应该使用运行时log4j.日志文件已创建但仍为空 - 不会发生任何日志条目.
设置如下:
WEB-INF/web.xml文件:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
Run Code Online (Sandbox Code Playgroud)
WEB-INF /班/ commons-logging.properties:
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
Run Code Online (Sandbox Code Playgroud)
WEB-INF/log4j.xml文件:
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
...
</appender>
<appender name="FILE" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${catalina.home}/logs/my.log"/>
...
</appender>
<logger name="my.package">
<level value="INFO"/>
</logger>
<root>
<level value="ERROR"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</log4j:configuration>
Run Code Online (Sandbox Code Playgroud)
创建了文件logs/my.log,但没有显示日志.这是tomcat控制台上的信息日志,但没有配置布局模式.
commons-logging-1.1.1.jar和log4j-1.2.14.jar包含在WEB-INF/lib中.知道这里有什么问题吗?
我有一个xsd文件Foo.xsd.我尝试了以下方法在WSDL文件中引用它,但它不起作用.
1)将xsd文件放在本地文件系统中并将其导入为
<xsd:import namespace="http://ws.test.com/" schemaLocation="file:///D:/wsdl/Foo.xsd"></xsd:import>
Run Code Online (Sandbox Code Playgroud)
2)将xsd文件放在Web根文件夹中并导入为
<xsd:import namespace="http://ws.test.com/" schemaLocation="http://localhost:8080/Xfire/Foo.xsd"></xsd:import>
Run Code Online (Sandbox Code Playgroud)
当我运行客户端时,我对响应对象的字段获取null.但是当我将类型定义嵌入到WSDL本身中时,这就有效.
我们如何指定外部xsds的路径?
我正在使用xFire 1.2.6生成Web服务.使用xFire WSGen ant任务生成客户端.
我有一个使用常春藤进行依赖管理的ant的项目构建.我没有ivysetting文件,但是ivy.xml具有以下依赖项(我想使用spring与slf4j而不是commons日志记录):
<configurations>
<conf name="compile" />
<conf name="runtime" extends="compile"/>
</configurations>
<dependencies>
<dependency org="org.springframework" name="spring-webmvc" rev="3.0.5.RELEASE" conf="compile->default">
<exclude org="commons-logging" name="commons-logging"/>
</dependency>
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" conf="compile->default" />
<dependency org="org.slf4j" name="jcl-over-slf4j" rev="1.6.1" conf="runtime->default" />
</dependencies>
Run Code Online (Sandbox Code Playgroud)
但是在解析编译配置时,commons-logging就解决了.我还尝试在显式spring-core依赖项上使用exclude,但commons-logging总是放在编译类路径中.
我的错是什么?是不是不使用Commons Logging描述的maven?这是常春藤虫吗?需要我特别的设置吗?常春藤有什么缓存吗?任何的想法?
我使用ant 1.8.2和ivy 2.2.0,在Eclipse中使用IvyDE也有同样的问题.
我有一个使用gradle 1.12的Java 8项目构建,它完美无缺.现在我想使用FindBugs,因为我使用Java 8,我必须使用FindBugs 3.但是构建依赖于findbugsMain:
:my-module:compileJava UP-TO-DATE
:my-module:processResources UP-TO-DATE
:my-module:classes UP-TO-DATE
> Building 6% > :my-module:findbugsMain
Run Code Online (Sandbox Code Playgroud)
生成的build.gradle包含以下内容:
apply plugin: 'java'
apply plugin: 'findbugs'
findbugs.toolVersion = '3.0.0'
dependencies {
compile 'com.google.code.findbugs:annotations:3.0.0'
…
}
Run Code Online (Sandbox Code Playgroud)
任何想法为什么构建被绞死?我该怎么办?
我有一个通用的Java类型,如下所示:
class Response<D> {
List<D> data;
}
Run Code Online (Sandbox Code Playgroud)
并希望创建类似于RAML 1.0(我是新手)的东西.
我的第一个方法是
types:
Response:
type: object
properties:
data: object[]
Run Code Online (Sandbox Code Playgroud)
并在使用它时
body:
type: Response
properties:
data: MyDataType[]
Run Code Online (Sandbox Code Playgroud)
从API-Workbench我总是得到"从Response继承的非法覆盖属性数据".
另一个想法是使用repeat:
types:
Response:
type: object
properties:
data: object
repeat: true
Run Code Online (Sandbox Code Playgroud)
和分别
body:
type: Response
properties:
data: MyDataType
repeat: true
Run Code Online (Sandbox Code Playgroud)
现在非法覆盖已经消失,但在API-Console中我现在得到一个"Uncaught TypeError".
怎么解决?或者我需要一种完全不同的方法?任何的想法?
编译具有内部类的泛型类时遇到问题.该类扩展了一个泛型类,也就是内部类.
这里实现的接口:
public interface IndexIterator<Element>
extends Iterator<Element>
{
...
}
Run Code Online (Sandbox Code Playgroud)
通用超类:
public abstract class CompoundCollection<Element, Part extends Collection<Element>>
implements Collection<Element>
{
...
protected class CompoundIterator<Iter extends Iterator<Element>>
implements Iterator<Element>
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
具有编译器错误的通用子类:
public class CompoundList<Element>
extends CompoundCollection<Element, List<Element>>
implements List<Element>
{
...
private class CompoundIndexIterator
extends CompoundIterator<IndexIterator<Element>>
implements IndexIterator<Element>
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
错误是:
type parameter diergo.collect.IndexIterator<Element> is not within its bound
extends CompoundIterator<IndexIterator<Element>>
^
Run Code Online (Sandbox Code Playgroud)
怎么了?代码用eclipse编译,但不用java 5编译器编译(我在mac和eclipse 3.5上使用ant和java 5).不,我无法将其转换为静态内部类.
我的gradle构建中有一个wsimport任务正常工作,直到Java 7:
task wsimport {
ext.destDir = file("${buildDir}/generated/java")
ext.wsdlSrc = file("src/main/resources/schema/example/my.wsdl")
ext.bindingSrc = file("src/main/resources/schema/example/bindings.xsd")
outputs.dir destDir
doLast {
ant {
destDir.mkdirs()
taskdef(name: 'wsimport',
classname: 'com.sun.tools.ws.ant.WsImport',
classpath: configurations.jaxws.asPath)
wsimport(keep: true,
package: 'net.example.my',
xnocompile: true,
quiet: true,
sourcedestdir: destDir,
wsdl: wsdlSrc,
binding: bindingSrc,
encoding: "UTF-8"
)
}
}
}
Run Code Online (Sandbox Code Playgroud)
切换到JDK 8(build 1.8.0-b129)时,出现以下错误:
java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: ... schema_reference:
Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.
Run Code Online (Sandbox Code Playgroud)
搜索问题我发现了以下帖子(令人惊讶地描述了Java 7的问题):https://github.com/stianh/gradle-jaxb-plugin/issues/20 …
我有一个(Spring Boot 1.5)REST服务器处理文件uploads(multipart/form-data)和一个使用jQuery fileupload的JS客户端.在大多数情况下它工作正常,但是当我想上传一个更大的文件(大约4MB)时,服务器会发现它超出了限制并发回包含错误消息的响应.
然而,似乎服务器停止读取请求(当然是正确的),这导致客户端管道损坏.在这种情况下,不处理响应.该fail回调函数调用的内容如下data.jqXHR(data.response未定义):
{"readyState":0,"responseText":"","status":0,"statusText":"error"}
Run Code Online (Sandbox Code Playgroud)
使用时进行呼叫curl,结果是:
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
curl: (55) Send failure: Broken pipe
{"files":[{"size":3863407,"error":"upload_uploadSizeExceeded"}]}
Run Code Online (Sandbox Code Playgroud)
所以返回了一个响应,但JS客户端似乎忽略了它.有没有选项让jQuery处理响应,即使请求只是部分发送?
顺便说一句:更奇怪的是,我在服务器日志中看到这样的请求重复了几次,这可能是JS中的一种重试机制?
java ×5
generics ×2
gradle ×2
java-8 ×2
ajax ×1
dependencies ×1
findbugs ×1
formatting ×1
inheritance ×1
ivy ×1
jqxhr ×1
localization ×1
log4j ×1
logging ×1
maven-2 ×1
maven-plugin ×1
raml ×1
slf4j ×1
surefire ×1
testng ×1
tomcat ×1
web-services ×1
wsimport ×1
xml ×1
xsd ×1