我是春天的新手。使用 jdk 1.7。我定义了一个类:
public class FileDetails {
String filePath;
String fineName;
String timeStamp;
public FileDetails(String filePath, String fineName, String timeStamp) {
this.filePath = filePath;
this.fineName= fineName;
this.timeStamp = timeStamp;
}
}
并尝试从与以下相同的包中的另一个类创建此类的列表:
public class otherClass{
@Autowired
private List<FileDetails> fileInfo;
public void addToList(){
fileInfo.add(new FileDetails("something","something","something");
}
}
这是我的应用程序上下文:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:annotation-config/>
<bean id="fileDetails" class="pacckageName.FileDetails" >
</bean>
</beans>
我收到错误:
null pointer exception on the line "fileInfo.add(new FileDetails("something","something","something");"
我在哪里做错了?