小编Jay*_*ann的帖子

适用于Servlet 3.0的Spring 4 Java Config for MultipartResolver

我正在采用全Java方法来进行Spring MVC配置,并且无法弄清楚如何以编程方式将MultipartConfigElement我与我联系起来DispatcherServlet.

Spring文档说明:

为了使用基于Servlet 3.0的多部分解析,您需要在web.xml中使用"multipart-config"部分标记DispatcherServlet,或者在程序化Servlet注册中使用javax.servlet.MultipartConfigElement标记...

http://docs.spring.io/spring/docs/4.0.4.RELEASE/spring-framework-reference/htmlsingle/#mvc-multipart

这是我的WebApplicationInitializer代码:

public class DispatcherServletInitializer implements WebApplicationInitializer {

    private static final Logger logger = LoggerFactory.getLogger(DispatcherServletInitializer.class);

    @Override
    public void onStartup(ServletContext container) {

        // Create the 'root' Spring application context
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(AppConfig.class);

        // Manage the lifecycle of the root application context
        container.addListener(new ContextLoaderListener(rootContext));

        // Create the dispatcher servlet's Spring application context
        AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext();
        dispatcherContext.register(WebConfig.class);

        //HOW CAN I ASSOCIATE THIS CONFIG WITH …
Run Code Online (Sandbox Code Playgroud)

java spring servlets spring-mvc spring-java-config

9
推荐指数
1
解决办法
1万
查看次数

使用Spring Data JPA和JPA EntityListener进行字段级加密

我正在尝试在插入/更新之前加密域实体上的少数字段,并在选择时解密它们以在UI中显示.

我正在使用带有Hibernate的Spring Data JPA存储库和一个EntityListener,它在@PostLoad生命周期事件期间解密并在@PrePersist和@PreUpdate期间加密.我遇到的问题是,一旦将记录从DB加载到PersistenceContext中,侦听器就会解密数据,这会使EntityManager认为实体已被更改,从而触发更新,从而再次触发@PreUpdate加密.关于如何处理这个问题的任何建议?

  • Spring 4.0.4.RELEASE
  • Spring Data JPA 1.5.2.RELEASE
  • Hibernate 4.2.14.Final

有没有简单的方法从JPA存储库返回分离的实体?

实体类

@Entity
@Table(name="cases")
@EntityListeners(EncryptionListener.class)
public class MyCase implements Serializable, EncryptionEntity {

private static final Logger logger = LoggerFactory.getLogger(MyCase.class);

private static final long serialVersionUID = 1L;

private String caseNumber;
private byte[] secretProperty;
private byte[] iv;

@Id
@Column(name="case_number")
public String getCaseNumber() {
    return caseNumber;
}
public void setCaseNumber(String caseNumber) {
    this.caseNumber = caseNumber;
}

@Column(name="secret_property")
public byte[] getSecretProperty() {
    return secretProperty;
}
public void setSecretProperty(byte[] secretProperty) {
    this.secretProperty = …
Run Code Online (Sandbox Code Playgroud)

java encryption spring hibernate jpa

7
推荐指数
1
解决办法
3668
查看次数

Spring 4, Hibernate JPA JarInputStreamBasedArchiveDescriptor Error on Websphere 8.5.5

I have a Spring MVC/Spring-Data-JPA (with Hibernate) application running perfectly on the Websphere 8.5.5 Liberty Profile. However, when I deploy to the full version of Websphere 8.5.5. I get the error pasted below.

My other beans naturally rely on the EntityManagerFactory, so this kills me. Have been googling all day to no avail.

  • Environment: Websphere 8.5.5
  • Spring Version: 4.0.4.RELEASE
  • Hibernate EntityManager Version: 4.3.5
  • IDE: IBM RAD (Version: 8.5.5) (Eclipse 3.6.3)

STACK TRACE:

[5/20/14 19:29:14:800 EDT] …
Run Code Online (Sandbox Code Playgroud)

spring hibernate hibernate-entitymanager websphere-8 spring-java-config

5
推荐指数
1
解决办法
2679
查看次数