小编roh*_*hit的帖子

java.lang.IllegalArgumentException:切入点处于:: 0正式未绑定时出错

Thinker.java

package springdemo2;

public interface Thinker {
    void thinkOfSomething(String thoughts); 
}
Run Code Online (Sandbox Code Playgroud)

Volunteer.java

package springdemo2;

public class Volunteer implements Thinker{
    private String thoughts;

    @Override
    public void thinkOfSomething(String thoughts) {
        this.thoughts=thoughts;
    }

    public String getThoughts(){
        return thoughts;
    }
}
Run Code Online (Sandbox Code Playgroud)

MindReader.java

package springdemo2;

public interface MindReader {
    void interceptThoughts(String thoughts);

    String getThoughts();
}
Run Code Online (Sandbox Code Playgroud)

Magician.java

package springdemo2;

import org.aspectj.lang.annotation.Aspect; 
import org.aspectj.lang.annotation.Before; 
import org.aspectj.lang.annotation.Pointcut;

@Aspect 
public class Magician implements MindReader {

    private String thoughts;

    @Pointcut("execution(* springdemo2."
            + "Thinker.thinkOfSomething(String)) and args(thoughts)")
    public void thinking(String thoughts){
    } …
Run Code Online (Sandbox Code Playgroud)

aop spring spring-aop

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

处理spring DataAccessException的位置

我使用Struts,Spring和Hibernate开发了一个应用程序.

我的DAO使用spring jdbc,并且它的所有方法都抛出DataAccessException(未选中).

我应该在哪里处理此例外情况?我知道这是一个未经检查的异常,但我想我需要告诉用户数据库或它的连接是否有问题.

我想我应该从我的服务类方法中重新抛出DataAccessException,以便被Controller捕获.这是一个好习惯吗?

我查看了Spring包中的示例,但未在域或服务区找到任何异常处理.离开dao区域后,似乎忽略了DataAccessException.

请为此事建议一个好的设计.

spring struts dao data-access exception-handling

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

org.hibernate.exception.SQLGrammarException:无法初始化集合

我有3个表tbl_category,tbl_Advertisment和tbl_linkcategoryadvert(有很多很多关联的黑白分类和广告)

我的POJO如下所示

Advertisment.java

@Entity
@Table(name="tbl_advertisment")
public class Advertisment implements Serializable {
    private long id;
    private String title;
    private String message;
    private Set<Category> categories;

    public Advertisment(String title, String message) {
        this.title = title;
        this.message = message;
        this.categories=new HashSet<Category>();
    }

    protected Advertisment() {
    }

    @Id
    @GeneratedValue
    protected long getId() {
        return id;
    }

    protected void setId(long id) {
        this.id = id;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Column(nullable=false)
    public String getTitle() …
Run Code Online (Sandbox Code Playgroud)

hibernate jpa

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

JSR验证API中的本地化支持,用于验证失败时的消息

我使用spring 3.0.2来开发一个像twitter这样简单的基于Web的应用程序.我的服务器端验证在JSR验证API方面表现良好,但在验证失败时,我无法找到任何在JSR验证API中国际化消息的方法.

我在我的模型类Spitter.java上使用以下注释来表示应用程序中的用户.

公共类Spitter实现Serializable {

private Long id;


@Size(min=8, max=15, message="some msg..")
@Pattern(regexp="^[a-zA-Z0-9]+$", message="some msg..")
private String username;

@Size(min=8, max=15, message="some msg..")
private String password;

@Size(min=3, max=15, message="some msg..")
private String name;

@Pattern(regexp="^$",message="some msg..")
private String email;

@NotNull(message="some msg..")
@NumberFormat(style= NumberFormat.Style.NUMBER)
@Min(value=14, message="some msg..")
@Max(value=99, message="some msg..")
private Integer age;

//getter setter not shown

}
Run Code Online (Sandbox Code Playgroud)

我已经检查了JSR Validation API,以便在验证失败时获得本地化支持,但无法找到相同的内容.

有什么方法可以实现国际化.

提前致谢...

spring-mvc jsr bean-validation

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