在使用GitHub进行项目时,我已经爱上了GitHub for Windows作为客户端.现在,一个新项目将在我将使用GitLab而不是GitHub的地方召唤.
我仍然可以使用GitHub for Windows作为GitLab的客户端吗?毕竟,他们都是基于git,对吧?如果没有,GitLab可以使用哪些客户端?
我的maven java项目使用maven-antrun-plugin来执行部署我的应用程序的deploy.xml ant脚本.deploy.xml使用该<if>
任务,这似乎导致了问题;
[INFO]执行任务
[taskdef]无法从资源net/sf/antcontrib/antlib.xml加载定义.它无法找到.部署:
[INFO] --------------------------------------------- ---------------------------
[ERROR] BUILD ERROR
[INFO] --------------- -------------------------------------------------- -------
[INFO]发生了Ant BuildException:执行此行时发生以下错误:
E:\ My_Workspace\xxxxxx\xxxxxx\xxxxxxx\deploy.xml:24:问题:创建任务或类型失败如果
原因:名称未定义.
行动:检查拼写.
操作:检查是否已声明任何自定义任务/类型.
操作:检查是否已发生任何<presetdef>/<macrodef>声明.
这是我的pom的antrun插件配置;
<plugin>
<inherited>false</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>remote-deploy</id>
<phase>install</phase>
<configuration>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>
<property name="compile_classpath" refid="maven.compile.classpath" />
<property name="runtime_classpath" refid="maven.runtime.classpath" />
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
<ant antfile="${basedir}/deploy.xml">
<target name="deploy" />
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId> …
Run Code Online (Sandbox Code Playgroud) 我经常看到人们明确地调用super()
一个没有明确扩展任何东西的类.
public class Foo
{
public Foo()
{
super();
//do other constructor stuff
}
}
Run Code Online (Sandbox Code Playgroud)
现在我知道这是完全合法的,如果省略,编译器会添加调用,但我仍然认为这是不好的做法.每当我看到这个,我想知道程序员是否对继承有误解,以及所有类都隐式扩展的事实Object
.
我应该将其添加到我们的编码标准/最佳实践中吗?当我看到他们这样做时,我是否应该将我团队中的其他开发人员拉出来?它是我个人的错误熊,但我不知道我是否只是挑剔.
我有一个Spring MVC控制器,带有一些简单的REST服务请求.我想在从我的服务中抛出特定异常时添加一些错误处理,但是我无法获得一个用@ExceptionHandler注释的处理程序方法来实际调用它.这是一个服务我故意抛出异常来尝试让我的处理程序方法接管.永远不会调用处理程序方法,Spring只会向调用客户端返回500错误.你对我做错了什么有什么想法吗?
@ExceptionHandler(IOException.class)
public ModelAndView handleIOException(IOException ex, HttpServletRequest request, HttpServletResponse response) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
System.out.println("It worked!");
return new ModelAndView();
}
@RequestMapping(value = "/json/remove-service/{id}", method = RequestMethod.DELETE)
public void remove(@PathVariable("id") Long id) throws IOException {
throw new IOException("The handler should take over from here!");
}
Run Code Online (Sandbox Code Playgroud) 我想首先通过检测cookie来解析用户的语言环境,如果没有,则通过accept-language标头解析.Spring似乎只想接受单一LocaleResolver
.
有趣的是,春天的文件为CookieLocaleResolver
州
LocaleResolver实现,使用在自定义设置的情况下发回给用户的cookie,回退到指定的默认语言环境或请求的accept-header语言环境.
但事实上似乎并非如此; 测试显示它不起作用,快速查看源显示它只有在没有cookie时才会获得默认值.
编写自己的LocaleResolver
实现是唯一的解决方案吗?
我正在使用javascript删除Cookie但由于某种原因它无法使用Chrome.我正在使用的脚本是;
function clearCookie()
{
document.cookie = 'myCookie=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/myPath/';
}
Run Code Online (Sandbox Code Playgroud)
这适用于;
..但不适用于Chrome 7.0.517.44,在cookie应该被清除之后我仍然可以看到它并且值没有改变.
有任何想法吗?Chrome中是否有任何用户设置可能会阻止我的Cookie被删除?
我最近参加了一次采访,并被问到以下问题.
有两个具有相同哈希码的对象.我在hashmap中插入这两个对象.
hMap.put(a,a);
hMap.put(b,b);
哪里 a.hashCode()==b.hashCode()
现在告诉我hashmap里面有多少个对象?
我回答说只有一个对象,因为哈希码相等,两个对象将相等,而hashmap不允许重复键.请告诉我,我的理解是否正确?
我想使用一种格式创建一个String,用bean中的属性替换格式的一些标记.是否有一个支持这个的库,或者我将不得不创建自己的实现?
让我举一个例子来证明.说我有一个豆子Person
;
public class Person {
private String id;
private String name;
private String age;
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
我希望能够指定类似的格式字符串;
"{name} is {age} years old."
"Person id {id} is called {name}."
Run Code Online (Sandbox Code Playgroud)
并使用bean中的值自动填充格式占位符,例如;
String format = "{name} is {age} old."
Person p = new Person(1, "Fred", "32 years");
String formatted = doFormat(format, person); //returns "Fred is 32 years old."
Run Code Online (Sandbox Code Playgroud)
我已经看了一下,MessageFormat
但这似乎只允许我传递数字索引,而不是bean属性.
我想assert
在我的Spring web-app中使用Java 关键字,主要是在我的域类(检查构造函数中的不变量),但我看不到如何启用运行时断言检查.
对于普通的java应用程序,我会使用-ea
带有java命令的开关,但我不知道如何使用Tomcat等来做到这一点.
这是推荐的东西,还是应该使用Spring框架中的"Assert"类?但是,我宁愿让我的域类没有Spring依赖项.
使用 Jersey 和 Jackson 创建 REST 接口,当列表字段中有 0 或 1 个元素时,如何将列表字段序列化为列表。例如:
@XmlRootElement(name="foo")
public class Foo {
@XmlElement
public List<Bar> getBars() {
return this.bars;
}
}
@Path("foo")
public FooResource {
@GET
public Foo getFoo() {
return theFoo;
}
}
Run Code Online (Sandbox Code Playgroud)
当 bar 没有元素时,结果序列化为null
,当它包含单个元素时,它序列化为该元素,而不是包含单个元素的数组。有没有办法让这些总是序列化为数组?
作为参考,我使用的是 Jersey 1.10 和 Jackson 1.9.2。
java ×8
spring-mvc ×3
ant-contrib ×1
collections ×1
cookies ×1
git ×1
gitlab ×1
inheritance ×1
jackson ×1
javascript ×1
jersey ×1
json ×1
maven ×1
rest ×1
spring ×1
tomcat ×1