我正在创建一个示例项目,如MKyong 的教程中所述。我正在使用日食。当我创建项目时,我找不到任何方法来编写@Value
注释。
我知道这看起来很愚蠢,但我根本无法解决这个问题。你能帮忙吗?
...
import org.springframework.beans.factory.annotation.*;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
@Component ("newSession")
public class Session implements DisposableBean, InitializingBean {
@Value ("3232")
private int id;
...
pom.xml:
...
<properties>
<spring.version>3.0.5.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
....
为糟糕的缩进(大量复制粘贴)和愚蠢的问题道歉。