以下の状況。私はDomain JpaRepository(インターフェース)システムが好きなので、スプリングデータを使いたいです。SpringFrameworkのないEJB3(javax)を使用したSpringデータ(JPA)JBOSS AS7
ここでは、私はSpringフレームワーク自体を使いたくないです。私はjavax。* ejb3仕様に固執したいと思います
私はプロジェクト構成を設定しようとしています。
私は、PESISTANCEレイヤーを表すspring-data-jpaというプロジェクトを持っています。私はそこに同義語を聞いたので、私は(@Autowiredするのではなく、代わりにスプリング@Serviceと@Injectの@Statelessを使用しています。persistancelayer内部AccountServiceのは、テストpurporsesのためにのみ存在している。
PersistanceModule(Eclipseproject)
|
|-com.ns.persistance
| |-domain
| |-Account
| |-repository
| |-AccountRepository (JpaRepositry interface)
| |-test
| |-AccountService (which contains a method do save a user in the database)
AccountRepository
public interface AccountRepository extends JpaRepository<Account, Long> {
Account findByUsername(String username);
}
春データ
をテストするためのテスト目的のためにアカウントサービス。@Stateless
public class AccountService {
@Inject
private AccountRepository ar;
public void createTestAccount() {
Account account = new Account();
account.setUsername("testAccount");
account.setPassword("sicheres passwort");
account.setEmail("[email protected]");
account.setCreationTime(new Date());
account.setLastModificationDate(new Date());
account = ar.save(account);
}
}
Workjob
@Singleton
public class SSService {
@EJB
AccountService as;
@Schedule(minute = "*/5", hour = "*", persistent = false)
public void doWork() {
System.out.println("WorkJob!!!!!!!");
//as.createTestAccount();
}
}
私は春-データ-config.xmlの
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<jpa:repositories base-package="com.ns.persistence.repository" />
</beans>
JBossがAccountServiceのがNULLである(nullポインタ)を私に言って続けています。私はいくつかの設定をするのを忘れていたと信じていますが、私はそれを諦めて、グーグルが私に簡単なSpringframeworkソリューションを提供し続けます。 私の質問: 私は何を欠場しましたか? 春データはEJB(javax)で動作するのですか、springframeworkを使用する必要がありますか?