@Autowiredアノテーションを使用してSpringフレームワークを使用してServiceクラスを取得しようとしています。
ここで、サービスを使用する必要がある私のクラス(このクラスはWebSocketServletによって呼び出されます)(呼び出し時にNullPointerExceptionが発生します):
public class SignupWebSocketConnection extends MessageInbound {
    private static final Logger log = LoggerFactory.getLogger(SignupWebSocketConnection.class);
    @Autowired
    private UserService userService;
    @Override
    protected void onOpen(WsOutbound outbound) {
        log.info("Connection done");
    }
    @Override
    protected void onClose(int status) {
        log.info("Connection close");
    }
    @Override
    protected void onBinaryMessage(ByteBuffer byteBuffer) throws IOException {
        log.warn("Binary message are not supported");
        throw new UnsupportedOperationException("Binary message are not supported");
    }
    @Override
    protected void onTextMessage(CharBuffer charBuffer) throws IOException {
        User userTest = new User("log", "pass", "ema");
        userService.create(userTest);
    }
}
ここに私のweb.xml:
<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext*.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
ここに私のApplicationContext.xml:
<bean id="userService" class="service.UserService">
ApplicationContext-test.xmlを明示的に呼び出してテストパッケージ(mavenを使用)でサービスを使用しようとすると、正常に機能しています... ApplicationContext.xmlとApplicationContext-test.xmlは同じです(データベースへのパラメーターのみ)変更)
みなさん、どうもありがとうございました:D
編集 :
applicationContext.xmlをressourcesフォルダーに置き、テストするクラスを作成します。
   public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService = (UserService) ctx.getBean("userService");
        User user = new User("log","pas","emai");
        userService.create(user);
    }
userService.create()を呼び出すときにもNullPointerExceptionが発生します...。