2014-02-28 42 views
0

我正在使用聲明性的方式使豆子彈簧managed.It工作正常。我現在計劃去註釋。 我跟着這個Tutorial使用@Component而不是聲明性聲明?

我所做的是

<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:component-scan base-package="com" /> 

</beans> 

和所使用的組件註釋

@Component 
public class EmployeeServiceImpl implements EmployeeService {} 

但是,當我開始我的web應用程序,我得到以下錯誤

java.lang.ClassNotFoundException: javax.annotation.Nullable 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)But when is start my web application i get below error 

更新: -在google上我發現javax.annotation.Nullable可以在jsr305-1.3.7.jar下找到。但我認爲jsr305-1.3.7.jar的缺失並不是問題,因爲我可以使它在沒有jsr305-1.3.7.jar的情況下在簡單的spring hello world項目中工作。所以我認爲問題在於其他地方。

+0

把jsr305-1.3.7.jar放在classpath中,並嘗試 – Naren

+0

Naren看到我的更新 – user3198603

+0

哪些春天的版本jar ur使用? – Naren

回答

0

jsr305-1.3.7.jar添加到您的類路徑中。你得到的例外,因爲JVM是無法找到所需的類

+0

請參閱我的更新 – user3198603

+0

這不是與彈簧罐有關的地方。您需要確保在類路徑中包含所有必需的jar – Keerthivasan