小编asy*_*ard的帖子

EJB 3.1或Spring 3 ..何时选择哪一个?

EJB在3.x版本中实现了许多改进,Spring也是常用的,而版本3是一个很好的选择.

网上有很多文章,但没有关于ejb3x与spring3x的确切比较.你对它们有什么想法,在现实世界的例子中哪个更好的条件?

例如,我们想要分离数据库和服务器,这意味着我们的应用程序将在服务器上,我们的数据库将在另一个服务器上.. EJB远程控制与Cluster4Spring等?

做每一个@Annotation总是好的?配置永远不需要?

comparison ejb-3.0 ejb-3.1 spring-3

41
推荐指数
4
解决办法
5万
查看次数

使用带有spring 3.1.0.release的hibernate 4.0的eventlisteners?

这些罐子都是新发布的,并且拥有最新的Java EE应用程序解决方案.但是我在hibernate.cfg.xml中指定hibernate监听器时遇到了问题.

在春季3.1.0之前,LocalSessionFactroyBean持有一个保存eventlisteners的属性.但是使用3.1.0.release没有eventlisteners地图.现在我无法在saveorupdate,postload等上保持模态对象的跟踪,因为它们不是由Spring配置的.你有想法解决这个问题吗?

java event-listener spring-3 hibernate-4.x

19
推荐指数
2
解决办法
3万
查看次数

如何从JSF中的另一个bean获取managedbean属性

我搜索了类似的问题,但我有点困惑.我有一个登录页面,所以LoginBean也是;

@ManagedBean(name = "loginBean")
@SessionScoped
public class LoginBean implements Serializable {    
    private String password="";
    private String image="";
    @ManagedProperty(value = "#{loginBeanIdentityNr}")
    private String identityNr="";
...
Run Code Online (Sandbox Code Playgroud)

成功后,导航到订单列表页面,所以我也有OrderBean.

@ManagedBean(name = "OrderBean")
@SessionScoped
       public class OrderBean {
            List<Ordery> sdList;

            public List<Order> getSdList() {

                try {

                    String identityNr ="";
                    ELContext elContext = FacesContext.getCurrentInstance().getELContext();
                    LoginBean lBean = (LoginBean) FacesContext.getCurrentInstance().getApplication().getELResolver().getValue(elContext, null, "loginBean");
                    identityNr =lBean.getIdentityNr();
                    sdList = DatabaseUtil.getOrderByIdentityNr(identityNr);
    ...
    }
Run Code Online (Sandbox Code Playgroud)

我不需要整个LoginBean,只需要ManagedProperty"loginBeanIdentityNr".但是下面这段代码不起作用(当然);

identityNr = (String) FacesContext.getCurrentInstance()
                        .getApplication().getELResolver()
                        .getValue(elContext, null, "loginBeanIdentityNr");
Run Code Online (Sandbox Code Playgroud)

这次它给我返回null.我想如果我需要整个bean属性,我可以注入这些bean,对吗?那么,你对这种方法有什么建议吗?可以<f:attribute>用吗?

jsf managed-bean

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

使用H2 db配置进行Spring测试

我在生产环境中使用Oracle,我想使用H2进行测试.我可以打字;

<jdbc:embedded-database id="dataSource">
  <jdbc:script location="classpath:schema.sql"/>
  <jdbc:script location="classpath:test-data.sql"/>
</jdbc:embedded-database>
Run Code Online (Sandbox Code Playgroud)

所以我的表和脚本是自动创建的.但是我无法设置此db的URL值.(对于H2-Oracle兼容性,我应该添加; MODE = Oracle到url部分)

有没有办法实现这个目标?

或者只是相反的解决方案;

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="org.h2.Driver"/>
    <property name="url" value="jdbc:h2:file:h2\db"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>        
</bean>
Run Code Online (Sandbox Code Playgroud)

在这个时候,我可以编辑URL部分,但是如何将默认测试脚本(创建和数据sqls)加载到此数据源?

h2 spring-test

16
推荐指数
2
解决办法
3万
查看次数

土耳其人字符上的Postgres上部功能不会返回预期结果

看起来postgres upper/lower函数不处理土耳其字符集中的选择字符.

select upper('Aa?'), lower('Aa?') from mytable;
Run Code Online (Sandbox Code Playgroud)

回报:

AA?, aa?
Run Code Online (Sandbox Code Playgroud)

代替 :

AAI, aai
Run Code Online (Sandbox Code Playgroud)

请注意,正常的英文字符转换正确,但不是土耳其语I(较低或较高)

Postgres版本: 9.2 32 bit

数据库编码(其中任何一个都是相同的结果): UTF-8, WIN1254, C

客户端编码:

 UTF-8, WIN1254, C
Run Code Online (Sandbox Code Playgroud)

OS: Windows 7 enterprise edition 64bit

SQL函数lowerupper在UTF-8编码数据库上为ı和İ返回以下相同的字节

\xc4b1    
\xc4b0   
Run Code Online (Sandbox Code Playgroud)

以及关于WIN1254(土耳其语)编码的数据库

\xfd      
\xdd     
Run Code Online (Sandbox Code Playgroud)

我希望我的调查是错误的,而且我错过了一些东西.

postgresql turkish character-encoding

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

使用模板时出现<h:outputScript>目标问题

我有一个关于将jquery库与JSF 2.0集成的问题

使用时<h:outputScript library="/common/js" name="jquery-1.5.1.min.js" target="head" />,我应该<h:head>在我的xhtml文件中包含标签.所以脚本呈现在头部.

但我有一个包含<h:head>,<h:body>部件的template.xhtml .如何target="head" />为我的页面制作这个模板ui:composition="template.xhtml"

target=form> 也没用.

我的模板:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><h:outputText value="#{msg['label.titlemsg']}" /></title>
    <h:outputStylesheet library="css" name="style.css"  target="head"/>
</h:head>

<h:body>
<f:view locale="#{localeBean.locale}">

<div id="outer">

  <div id="container"> 
    <div id="inner"> 

      <div class="float">
        <div class="main"> 
          <!-- -->
          <div id="icerik"> 

              <ui:insert name="icerik">



      </ui:insert>
    </div></div></div></div></div></div>

     <div id="langbar" align="center">


    </div> …
Run Code Online (Sandbox Code Playgroud)

jsf facelets

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

使用 Spring 和 AspectJ 将基于方面的注释定位到类上

如何制作一个面向属于用特定注释标记的类的所有公共方法的方面?下面的method1()method2()应该由切面处理,而method3()不应该由切面处理。

@SomeAnnotation(SomeParam.class)
public class FooServiceImpl extends FooService {
    public void method1() { ... }
    public void method2() { ... }
}

public class BarServiceImpl extends BarService {
    public void method3() { ... }
}
Run Code Online (Sandbox Code Playgroud)

如果我将注释放在方法级别,则此方面将起作用并匹配方法调用。

@Around("@annotation(someAnnotation)")
public Object invokeService(ProceedingJoinPoint pjp, SomeAnnotation someAnnotation) 
 throws Throwable { 
   // need to have access to someAnnotation's parameters.
   someAnnotation.value(); 
Run Code Online (Sandbox Code Playgroud)

}

我正在使用 Spring 和基于代理的方面。

java aop spring annotations aspectj

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

sun.security.provider.SHA2使用100%cpu并在一段时间后挂起5分钟

我有一个奇怪的行为,也许你可以帮助我.

环境是

  • jdk_7u40(尝试jdk_7u51具有相同的行为)
  • debian 6.0(在windows上我从未遇到过这个问题)
  • jboss 7.1.1
  • Geoserver 2.4.x(尝试.3和.4,结果相同),它基于spring框架
  • 其他战争模块(不是基于弹簧的,但geoserver对它们有一些依赖)

问题是,在jboss运行几个小时之后,当我尝试登录geoserver的web界面(对j_spring_security servlet的POST)时,花了很多时间(4-5分钟)登陆欢迎页面应用程序.

使用jstack,我发现有一个线程一直消耗100%的核心,并且这个过程在这里继续工作

at sun.security.provider.SHA2.lf_S(SHA2.java:162)
at sun.security.provider.SHA2.lf_sigma0(SHA2.java:171)
at sun.security.provider.SHA2.implCompress(SHA2.java:225)
at sun.security.provider.SHA2.implDigest(SHA2.java:118)
at sun.security.provider.DigestBase.engineDigest(DigestBase.java:186)
at sun.security.provider.DigestBase.engineDigest(DigestBase.java:165)
at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:576)
at java.security.MessageDigest.digest(MessageDigest.java:353)
at java.security.MessageDigest.digest(MessageDigest.java:399)
at org.jasypt.digest.StandardByteDigester.digest(StandardByteDigester.java:979)
- locked <0x00000006f8c30bb0> (a java.security.MessageDigest$Delegate)
at org.jasypt.digest.StandardByteDigester.matches(StandardByteDigester.java:1099)
at org.jasypt.digest.StandardStringDigester.matches(StandardStringDigester.java:1052)
at org.jasypt.util.password.StrongPasswordEncryptor.checkPassword(StrongPasswordEncryptor.java:99)
at org.jasypt.spring.security3.PasswordEncoder.isPasswordValid(PasswordEncoder.java:204)
at org.geoserver.security.password.AbstractGeoserverPasswordEncoder.isPasswordValid(AbstractGeoserverPasswordEncoder.java:138)
at org.geoserver.security.password.GeoServerMultiplexingPasswordEncoder.isPasswordValid(GeoServerMultiplexingPasswordEncoder.java:75)
at org.springframework.security.authentication.dao.DaoAuthenticationProvider.additionalAuthenticationChecks(DaoAuthenticationProvider.java:64)
Run Code Online (Sandbox Code Playgroud)

有些人有类似的问题吗?

编辑(有解决方法)

我发现问题与CMS垃圾收集器和permgen空间的增加有关.

环境

应用程序服务器是JBoss 7.1.1,其中部署了5个war(Geoserver等).所有战争都有共同的依赖关系(也有Geoserver); Java正在运行-XX:+UseParallelOldGC -XX:SoftRefLRUPolicyMSPerMB=36000

怎么了

当执行一个完整的GC,PermGen的空间增加了许多上方的使用.之后,方法的计算sun.security.provider.SHA2.*变得非常缓慢.

我是怎么解决的

转移到G1GC垃圾收集器为我解决了问题(目前我正在使用以下选项-XX:+UseG1GC -XX:-UseAdaptiveSizePolicy -XX:SurvivorRatio=1 -XX:NewRatio=1 -XX:MaxTenuringThreshold=15 -XX:G1HeapRegionSize=32m)

java spring geoserver jboss7.x

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

Bootstrap在Firefox浏览器中不起作用

我有一个Bootstrap表单,但它在Firefox中没有正确显示...所有其他浏览器似乎都有效.我已经尝试了一切!

这是链接:http://www.redmandesign.ie/bootstrap/form1.html

我认为这与bootstrap样式表有关,但我不确定.

任何人都可以帮忙,我真的被困了!!!

firefox twitter-bootstrap

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