我實際上在JPA的springboot項目上工作。我在尋找一個更好的實施,目前它的工作原理,但我的印象中,這是不是最好的辦法聲明createEntityManagerFactory的最佳方法
@RestController
public class inscription {
EntityManagerFactory objFactory = Persistence.createEntityManagerFactory("com.myapplication_jar_0.0.1-SNAPSHOTPU");
UserJpaController userCtrl = new UserJpaController(objFactory);
SerialsJpaController licenseCtrl = new SerialsJpaController(objFactory);
@CrossOrigin(origins = CURRENT_IP)
@RequestMapping(value = "/createaccount", method = RequestMethod.GET)
public CreatAccountResponseTemplate createAccount(
@RequestParam(value = "login") String login,
@RequestParam(value = "password") String password,
)
{
EntityManager manager = objFactory.createEntityManager();
CreatAccountResponseTemplate responseTemplate = new CreatAccountResponseTemplate();
...}
「最好的」 是主觀的。本網站不是根據常見問題的主觀問題 –