小编zb2*_*226的帖子

避免"资源与文件系统不同步"

我使用Eclipse开发Java代码并定期收到以下消息:

资源与文件系统不同步.

右键单击>刷新将始终清除此项.

但是为什么Eclipse在找到这种情况时不能自动刷新?是否存在您希望资源不同步的情况?

如果有这样的条件并且它们不适用于我的工作,有没有办法让Eclipse在遇到这种状态时自动刷新?(我很欣赏它应该在正常开发中尽可能少地刷新,以提高人类开发人员的性能.)

更新(2012-06-25):我的最新更新(版本:Indigo Release Build id:20110615-0604)不再显示首选项 - 常规 - 工作区 - 自动刷新有一个选项"访问时刷新" - 我应该使用它吗?

eclipse

265
推荐指数
5
解决办法
18万
查看次数

webdriver.Dispose(),. Close()和.Quit()之间的区别

这些之间有什么区别

  1. Webdriver.Close()
  2. Webdriver.Quit()
  3. Webdriver.Dispose()

哪一个和什么时候使用?

selenium-webdriver

265
推荐指数
7
解决办法
24万
查看次数

为什么带有全局标志的RegExp会产生错误的结果?

当我使用全局标志和不区分大小写的标志时,这个正则表达式有什么问题?查询是用户生成的输入.结果应该是[true,true].

var query = 'Foo B';
var re = new RegExp(query, 'gi');
var result = [];
result.push(re.test('Foo Bar'));
result.push(re.test('Foo Bar'));
// result will be [true, false]
Run Code Online (Sandbox Code Playgroud)

var reg = /^a$/g;
for(i = 0; i++ < 10;)
   console.log(reg.test("a"));
Run Code Online (Sandbox Code Playgroud)

javascript regex

254
推荐指数
4
解决办法
4万
查看次数

Maven:什么是pluginManagement?

这是我的pom文件的片段.

....
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>                        
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            ......
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
...
Run Code Online (Sandbox Code Playgroud)

我在命令中成功使用它

mvn install
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试将其封装到"pluginManagement"标签中时,maven-dependency-plugin当我启动install目标时停止工作.为什么"pluginManagement"标签会改变构建行为?或者我应该使用其他目标或选项?

java build pom.xml maven maven-dependency-plugin

242
推荐指数
3
解决办法
14万
查看次数

如何创建私有类方法?

为什么这种创建私有类方法的方法有效:

class Person

  def self.get_name
    persons_name
  end

  class << self

    private

    def persons_name
      "Sam"
    end
  end
end

puts "Hey, " + Person.get_name
puts "Hey, " + Person.persons_name  #=> raises "private method `persons_name' called for Person:Class (NoMethodError)"
Run Code Online (Sandbox Code Playgroud)

但这不是:

class Person

  def self.get_name
    persons_name
  end

  private

  def self.persons_name
    "Sam"
  end
end

puts "Hey, " + Person.get_name
puts "Hey, " + Person.persons_name
Run Code Online (Sandbox Code Playgroud)

ruby access-specifier

213
推荐指数
6
解决办法
9万
查看次数

如何使用Jackson JSON处理器序列化Joda DateTime?

如何根据一个简单的模式(如"dd-MM-yyyy")让杰克逊序列化我的Joda DateTime对象?

我试过了:

@JsonSerialize(using=DateTimeSerializer.class)
private final DateTime date;
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

ObjectMapper mapper = new ObjectMapper()
    .getSerializationConfig()
    .setDateFormat(df);
Run Code Online (Sandbox Code Playgroud)

谢谢!

java json jodatime jackson

117
推荐指数
7
解决办法
13万
查看次数

Java和0xff的值是什么?

我有以下Java代码:

byte value = 0xfe; // corresponds to -2 (signed) and 254 (unsigned)
int result = value & 0xff;
Run Code Online (Sandbox Code Playgroud)

打印时结果是254,但我不知道这段代码是如何工作的.如果&运算符只是按位,那么为什么它不会产生一个字节而是一个整数呢?

java byte integer bitwise-and

91
推荐指数
3
解决办法
10万
查看次数

Maven依赖spring-web vs spring-webmvc

以下依赖项之间有什么区别?

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

VS

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

如果我spring-webmvc单独包含,则spring-web隐式添加.

什么时候应该spring-web单独使用?

spring spring-mvc maven

90
推荐指数
2
解决办法
4万
查看次数

88
推荐指数
6
解决办法
63万
查看次数

log4j:WARN在web.xml中找不到logger的appender

我已经将log4jConfigLocation放在web.xml中,但我仍然收到以下警告:

log4j:WARN No appenders could be found for logger ?
    ? (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
    "java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml
        </param-value>
    </context-param>
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.util.Log4jConfigListener
        </listener-class>
    </listener>
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <servlet>
        <servlet-name>suara2</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>suara2</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)

java spring log4j spring-mvc

79
推荐指数
6
解决办法
29万
查看次数