我正在Spring Hibernate MVC中处理Web应用程序项目.我在Spring安全性中使用Bcrypt算法将编码密码存储在数据库中.现在我想要解码该编码密码以停用使用帐户我在给用户电子邮件和密码的位置,以便在用户停用帐户之前进行验证.我在获取解码密码时遇到问题.任何人都可以帮助我摆脱它或任何替代解决方案满足我的要求吗?
我在测试时遇到了这个问题 - 为类提供了错误类型的 idcom.myapp.ibank.domain.Customer. Expected: class java.lang.Long, got class java.lang.String
老实说,我不明白为什么我会得到这个以及到底发生了什么。当我正常使用它时,比如在本地tomcat上运行并通过控制器保存然后服务,它工作得很好。没有错误。这种行为对我来说毫无意义。
我正在使用 JPA 2.1 和 Hibernate 作为提供程序。
这是测试代码:
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextHierarchy({
@ContextConfiguration(classes = RootConfig.class),
@ContextConfiguration(classes = WebConfig.class)
})
@Transactional
public class AccountRepositoryTest {
@Autowired
private WebApplicationContext wac;
@Autowired
private AccountRepository accountRepository;
@Autowired
private CustomerService customerService;
private MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
Customer cus = new Customer();
cus.setFirstName("John");
cus.setLastName("Smith");
customerService.save(cus);
}
@Test
public void testSaveAccount() {
Account account = new Account();
account.setCustomer(customerService.findByName("John"));
account.setName();
account.setDebitCard(new DebitCard((long) …Run Code Online (Sandbox Code Playgroud) 有人可以解释"如何使用Spring Hibernate MVC将CSV文件上传到数据库?"
我将我的应用程序部署到glassfish 3.1服务器时出现以下错误,
加载应用时出现异常:
java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自ServletContext资源的XML文档中的第20行[/WEB-INF/applicationContext.xml]是无效的; 嵌套异常是org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'jms:listener-container'的声明..
请参阅server.log以获取更多细节.
我正在尝试在 JPA 存储库中添加 2 个相同的方法名称。我不确定这是否可能。
这就是我实际上在 JPA 接口中尝试做的事情:
public interface TbiDDCustomQueryConfigDao extends CrudRepository<TbiDDCustomQueryConfig, Integer>, JpaRepository<TbiDDCustomQueryConfig, Integer>{
@Query("select c from TbiDDCustomQueryConfig c, TbiDataSource d where c.datasourceId= d.dataSourceId and c.tbiDDConfigMaster.ddConfigId = ?1 and c.isActive = ?2 and d.isActive='Y'")
List<TbiDDCustomQueryConfig> findByDdConfigIdAndIsActive(Integer ddConfigId,String isActive);
TbiDDCustomQueryConfig findByDdConfigIdAndIsActive(Integer ddConfigId,String isActive);
}
Run Code Online (Sandbox Code Playgroud)
编译错误告诉我重命名该方法。我改变了第二种方法如下:
TbiDDCustomQueryConfig findByDdConfigIdAndIsActive1(Integer ddConfigId,String isActive);
Run Code Online (Sandbox Code Playgroud)
但是当我运行代码时,出现错误:
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.acinfotech.timebound.jpa.dao.TbiDDCustomQueryConfigDao com.acinfotech.timebound.jpa.service.ReportJobsPersistenceServiceImpl.tbiDDCustomQueryDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tbiDDCustomQueryConfigDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: …Run Code Online (Sandbox Code Playgroud)