草庐IT

存储库

全部标签

java - 如何在 Spring Boot 中实现通用 JPA 存储库——它可以自动连接到任何实体/类类型的 spring 服务中

这是扩展了springPagingAndSortingRepository的示例GenericRepository实现,@NoRepositoryBeanpublicinterfaceGenericRepositoryextendsPagingAndSortingRepository{publicListfindByNamedQuery(Stringname);publicListfindByNamedQueryAndParams(Stringname,Mapparams);publicTfindOneByNamedQuery(Stringname);publicTfindOneByN

java - 如何在单元测试中模拟 JPA 存储库的保存方法

比如我在UserService中有这个方法:@Override@TransactionalpublicUserDtocreate(UserDtouserDto){UserdbUser=userRepository.findOne(userDto.getId());if(dbUser!=null){thrownewAuthException(AuthException.ErrorCode.DUPLICATE_USER_EXCEPTION);}UseroneByLogin=userRepository.findOneByLogin(userDto.getLogin());if(oneByL

java - @Autowired bean 在 Controller 上与@Valid 一起工作,但在 CRUD 存储库上失败

我正在开发一个带有用户注册表单的SpringMVC+Hibernate+JPA应用程序,我决定使用JSR-303validator来检查用户名是否已存在于数据库中:publicclassUniqueUsernameValidatorimplementsConstraintValidator{@AutowiredUserServiceuserService;@Overridepublicvoidinitialize(VerifyUniqueUsernameconstraintAnnotation){}@OverridepublicbooleanisValid(Stringusername

java - Maven 没有从 settings.xml 中为存储库选择用户名

我的~/.m2/settings.xml中有这个:deploymentxxxxxxcentraldeploymentxxxxxxsnapshots这在我的POM中:centrallibs-release-localhttp://repo.example.com:8081/nexus/content/repositories/libs-release-localsnapshotslibs-localhttp://repo.example.com:8081/nexus/content/repositories/libs-local我面临的问题是Artifact没有部署,nexus日志显示用

使用2个远程存储库

为了学习git,我做了两个回购,直到现在,我一直在从本地的一个远程存储库中推出一个远程存储库。我刚刚做了第二个遥控器,并想将所有代码放在其中。目前,我本地的存储库有很多未跟踪的文件和未铺设的更改。如何将所有文件从本地存储库中获取到新的远程存储库?看答案进入第一把手,创建一个新的remote(说,secondRepo)带有URLsecond-repo.#runinfirst-repo$gitaddremotesecondRepo$gitfetchsecondRepo现在,结帐到一个新分支(说,feature)。做Add,Commit您的本地更改,推到新遥控器(在这里,secondRepo)分支(

java - 如何从 Maven 3.0 插件获取本地存储库位置?

如何从Maven3.x插件中获取本地存储库位置(URI)? 最佳答案 按照thisblogpost中的说明使用Aether./***Thecurrentrepository/networkconfigurationofMaven.**@parameterdefault-value="${repositorySystemSession}"*@readonly*/privateRepositorySystemSessionrepoSession;现在通过RepositorySystemSession.getLocalRepository

java - Maven 3 不从本地存储库更新快照依赖项

我正在尝试在我的Maven项目中使用外部库。因为我希望项目在任何机器上开箱即用,所以我不想使用mvninstall解决方案。因此,我在我的pom.xml中定义了本地存储库:com.testfooLib1.0-SNAPSHOT....in-projectalwaystrueInProjectRepofile://${project.basedir}/libRepo问题是当我替换libRepo中的jar时(没有更新版本号,因为它只是另一个快照)没有使用这个更新的jar(旧版本来自.m2目录被代替)甚至对于mvn-Ucleaninstall如何让maven更新这个jar?编辑:根据Whate

java - Spring Web 应用程序中 Controller 、服务、存储库的范围?

我正在使用spring和hibernate创建一个web应用程序。假设多个用户想要注册。我将创建一个注册bean(原型(prototype)或请求或session范围)并在Controller中Autowiring它。现在我将此bean传递给注册服务(使用“@transactional”注释进行注释),该服务也在Controller中Autowiring。此服务会将收到的注册bean对象传递给DAO(此DAO在服务中Autowiring)如果服务和DAO是单一的,那么多个用户的请求不会混淆吗?这是我所做的:我创建了服务范围和DAO作为“请求”。这是正确的方法吗?或者我还能做些什么来使服

java - spring-data-cassandra 存储库的多键空间支持?

SpringDataCassandra是否支持同一应用程序上下文中的多个键空间存储库?我正在使用以下JavaConfig类设置cassandraspring数据配置@Configuration@EnableCassandraRepositories(basePackages="com.blah.repository")publicclassCassandraConfigextendsAbstractCassandraConfiguration{@OverridepublicStringgetKeyspaceName(){return"keyspace1";}在将存储库类移动到不同的包后

java - 为什么 Spring Data 存储库方法参数名称在 Java 8 上也不可用?

我很难让spring-boot1.4版本的Pivotal示例项目通过测试fromtheirexamples它显示spring-data-jpa在其JPQL中使用unannotated命名参数例如fromexample.springdata.jpa.simple.SimpleUserRepository@Query("selectufromUseruwhereu.firstname=:firstname")ListfindByFirstname(Stringfirstname);注意它没有使用@Param注解这不能在我的机器上运行。我在这里详细了解了异常,从标题中可以不言自明。Namef