小编Vai*_*hav的帖子

挥发性Vs原子

我读到了下面的某个地方.

Java volatile关键字并不意味着原子,它常见的误解是,在声明volatile之后,++操作将是原子的,要使操作原子化,你仍然需要确保使用synchronizedJava中的方法或块进行独占访问 .

那么如果两个线程同时攻击一个volatile原始变量会发生什么呢?

这是否意味着,凡发生在它的锁,将要设置其值.如果在此期间,一些其他的线程来和读取旧值,而第一个线程正在改变它的价值,那么没有新的线程将读取其旧的价值?

Atomic和volatile关键字有什么区别?

java volatile

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

"无法解析导入org.springframework."

<project>
    <properties>
        <jdk.version>1.6</jdk.version>
        <spring.version>3.2.2.RELEASE</spring.version>
        <spring.batch.version>2.2.0.RELEASE</spring.batch.version>
        <mysql.driver.version>5.1.25</mysql.driver.version>
        <junit.version>4.11</junit.version>
    </properties>

    <dependencies>

        <!-- Spring Core -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Spring jdbc, for database -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Spring XML to/back object -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- MySQL database driver -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.driver.version}</version>
        </dependency>

        <!-- Spring Batch dependencies -->
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-core</artifactId>
            <version>${spring.batch.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-infrastructure</artifactId>
            <version>${spring.batch.version}</version>
        </dependency>

        <!-- Spring Batch unit test -->
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-test</artifactId>
            <version>${spring.batch.version}</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version> …
Run Code Online (Sandbox Code Playgroud)

java eclipse maven

34
推荐指数
5
解决办法
19万
查看次数

多个@RequestMapping用于Spring MVC中控制器类中的方法

我在Spring MVC的控制器类中有一个方法.

@RequestMapping("/home")
    public void contactHomeDispatcher(){
    ...
    }
Run Code Online (Sandbox Code Playgroud)

是否可以为此方法映射另一个网址说"/ contact".我的问题是,是否可以为控制器中的单个方法提供多个请求映射.

spring-mvc

19
推荐指数
1
解决办法
2万
查看次数

无法实例化bean类:指定的类是一个接口

我知道有类似这个问题的线程.下面是我的类,我在spring.xml文件中配置它.实际上HumanResourceService是一个只有一个方法的接口.

@Endpoint
public class HolidayEndpoint {

    @Autowired
    private HumanResourceService humanResourceService;

    @Autowired
    public HolidayEndpoint(HumanResourceService humanResourceService) throws JDOMException {
        this.humanResourceService = humanResourceService;
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是在我的spring.xml文件中,当我将HumanResourceService定义为bean时,它无法实例化,因为这是一个接口.如何在spring配置文件中提及接口.我的spring.xml文件如下

<bean id="holidayEndpoint" class="com.mycompany.hr.ws.HolidayEndpoint" autowire="constructor" >
     <property name="humanResourceService" ref="humanResourceService" />
</bean>
<bean id="humanResourceService" class="com.mycompany.hr.service.HumanResourceService" />
Run Code Online (Sandbox Code Playgroud)

spring

9
推荐指数
1
解决办法
3万
查看次数

我们可以在Spring MVC中的Controller中获取HttpRequest对象吗?

我可以在Spring MVC的Controller类中获取HttpRequest对象吗?

@Controller
public class ContactController {

    @Autowired
    private ContactService contactService; 

    @RequestMapping("/login")
    public String displayLoginPage(@ModelAttribute("login") Login login, BindingResult result) {
        return "login";
    }
}
Run Code Online (Sandbox Code Playgroud)

spring-mvc

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

标签 统计

java ×2

spring-mvc ×2

eclipse ×1

maven ×1

spring ×1

volatile ×1