我有一个Spring 2.5/Java/Tomcat应用程序.有以下bean,在许多地方的整个应用程序中使用
public class HibernateDeviceDao implements DeviceDao
Run Code Online (Sandbox Code Playgroud)
和以下新的bean:
public class JdbcDeviceDao implements DeviceDao
Run Code Online (Sandbox Code Playgroud)
第一个bean配置为(包括所有bean)
<context:component-scan base-package="com.initech.service.dao.hibernate" />
Run Code Online (Sandbox Code Playgroud)
第二个(新)bean是单独配置的
<bean id="jdbcDeviceDao" class="com.initech.service.dao.jdbc.JdbcDeviceDao">
<property name="dataSource" ref="jdbcDataSource">
</bean>
Run Code Online (Sandbox Code Playgroud)
当然,这会导致启动服务器时出现异常:
嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义类型为[com.sevenp.mobile.samplemgmt.service.dao.DeviceDao]的唯一bean:期望的单个匹配bean但找到2:[deviceDao,jdbcDeviceDao]
从一个试图像这样自动装豆的类
@Autowired
private DeviceDao hibernateDevicDao;
Run Code Online (Sandbox Code Playgroud)
因为有两个bean实现相同的接口.
是否可以配置bean以便这样做
1.我不必对已经HibernateDeviceDao自动装配的现有类进行更改
2.仍然可以像这样使用第二个(新)bean:
@Autowired
@Qualifier("jdbcDeviceDao")
Run Code Online (Sandbox Code Playgroud)
即我需要一种方法将HibernateDeviceDaobean 配置为要自动装配的默认bean,同时允许在使用注释JdbcDeviceDao显式指定时使用@Qualifier.
我试过设置属性
autowire-candidate="false"
Run Code Online (Sandbox Code Playgroud)
在JdbcDeviceDao的bean配置中:
<bean id="jdbcDeviceDao" class="com.initech.service.dao.jdbc.JdbcDeviceDao" autowire-candidate="false">
<property name="dataSource" ref="jdbcDataSource"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
因为Spring文档说明了这一点
指示在查找匹配候选项以满足另一个bean的自动装配要求时是否应考虑此Bean.请注意,这不会影响名称的显式引用,即使指定的bean未标记为autowire候选,也会解析引用.*
我解释为我仍然可以JdbcDeviceDao使用@Qualifier注释自动装配并具有HibernateDeviceDao默认bean.显然,我的解释是不正确的,因为这会在启动服务器时导致以下错误消息:
类型[class com.sevenp.mobile.samplemgmt.service.dao.jdbc.JdbcDeviceDao]的不满意依赖:预计至少有一个匹配的bean
来自我尝试使用限定符自动装配bean的类:
@Autowired
@Qualifier("jdbcDeviceDao")
Run Code Online (Sandbox Code Playgroud)
我正在运行一个非英语的Windows 7系统,显然Oracle SQL Developer(版本3.0.04.34,64位)试图根据操作系统自动猜测我的首选语言.有没有办法将语言改为英语?
我已经尝试过在http://misteratmisis.com/infotech/how-change-oracle-sql-developer-interface-japanese-english找到的提示,即添加VM选项
AddVMOption -Duser.language=en AddVMOption -Duser.country=US
在目录中存档ide.conf
/ide/bin
在SQL Developer安装目录中,如建议的那样,但这没有帮助.
解决方案(2012年9月13日编辑):
我决定再次尝试Alex K.提出的解决方案,这次它起作用,即添加
AddVMOption -Duser.language=en
Run Code Online (Sandbox Code Playgroud)
到sqldeveloper.conf位于sqldeveloper\bin\文件夹中的文件文件.我认为它现在可以正常工作,但之前没有,因为同时我在Windows 7中更改了我的UAC(用户访问控制)设置,因此默认情况下我是管理员.之前发生的事情可能是即使变化似乎存在,程序读取的配置文件也是另一个(阴影副本).
适用于Mac OS X的解决方案(2016年2月26日添加):
编辑文件
/Applications/SQLDeveloper.app/Contents/Resources/sqldeveloper/sqldeveloper/bin/sqldeveloper.conf
并添加该行
AddVMOption -Duser.language=en
Run Code Online (Sandbox Code Playgroud)
(使用SQL Developer 4.1.3.20测试)
我开发了一个PHP Web服务.我想记录使用此Web服务的WS客户端的所有传入连接.如何获取客户端的IP地址?的价值
$_SERVER['HTTP_CLIENT_IP']Run Code Online (Sandbox Code Playgroud)
好像总是空着的. 我正在考虑将应用程序开发为portlet,以便集成到Liferay门户中.开发此类应用程序是否存在任何明显的缺点或限制,而不是使用Spring框架开发普通的Web应用程序?
Liferay似乎要求将所有内容添加为portlet.我想到的另一个选择是将Liferay仅用于应用程序的某些部分,并添加外部链接到其他自行开发的内容,这些内容是作为普通的Web应用程序开发的.但是,这将需要多个用户身份验证机制以及Liferay与其他Web应用程序之间的某种跨站点身份验证.
哪种方式最好?
我有SQL语句(SQL Server)
SELECT
COUNT(ActionName) AS pageCount
FROM tbl_22_Benchmark
WHERE DATEPART(dw,CreationDate)>1 AND DATEPART(dw,CreationDate)<7
GROUP BY
dateadd(dd,0, datediff(dd,0,CreationDate))
产生输出
pageCount
27
19
59
现在我想用SQL获得所有这些数字的平均值.显然嵌套的聚合函数就像
(AVG(COUNT(PAGECOUNT)))
是不允许的,并使用子查询
SELECT AVG(pageCount) FROM
(
SELECT
COUNT(ActionName) AS pageCount
FROM tbl_22_Benchmark
WHERE DATEPART(dw,CreationDate)>1 AND DATEPART(dw,CreationDate)<7
GROUP BY
dateadd(dd,0, datediff(dd,0,CreationDate))
)
得到我只是一个错误消息')'附近的语法不正确.
如何获得pageCount行的平均值?
我刚刚从英文下载网站http://qt.nokia.com/downloads下载并安装了我的英文Windows 7系统上的Qt Creator 1.3.1.然而,显然,Qt Creator的UI是用德语写的,尽管有帮助文件是英文的.
来自http://www.qt.gitorious.org/qt-creator/pages/FrequentlyAskedQuestions的常见问题解答我找到了答案
Qt Creator使用其运行的系统的语言设置.在Linux系统上,您还可以通过在启动Qt Creator之前设置LANG环境变量来覆盖该语言,例如在命令行上LANG = de ./qtcreator将运行带有德语接口的Qt Creator.
然而,这显然是不正确的,因为我有一个英文Windows,并且作为系统区域设置我有"英语(英国)"设置.可能Qt Creator错误地解释了"当前位置"的Windows设置,我将其设置为"德国"意味着德语也将是我的语言.但是,更改该值显然没有效果(可能应该在安装Qt Creator之前完成).
安装后,有没有办法将Qt creator的UI语言更改为英语,最好不要调整全局系统设置?
我有一个使用Spring 2.5.6和Spring Security 2.0.4的Web应用程序.我已经实现了一个工作登录页面,它根据Web服务对用户进行身份验证.通过定义自定义验证管理器来完成身份验证,如下所示:
<beans:bean id="customizedFormLoginFilter"
class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter">
<custom-filter position="AUTHENTICATION_PROCESSING_FILTER" />
<beans:property name="defaultTargetUrl" value="/index.do" />
<beans:property name="authenticationFailureUrl" value="/login.do?error=true" />
<beans:property name="authenticationManager" ref="customAuthenticationManager" />
<beans:property name="allowSessionCreation" value="true" />
</beans:bean>
<beans:bean id="customAuthenticationManager"
class="com.sevenp.mobile.samplemgmt.web.security.CustomAuthenticationManager">
<beans:property name="authenticateUrlWs" value="${WS_ENDPOINT_ADDRESS}" />
</beans:bean>
Run Code Online (Sandbox Code Playgroud)
身份验证管理器类:
public class CustomAuthenticationManager implements AuthenticationManager, ApplicationContextAware {
@Transactional
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
//authentication logic
return new UsernamePasswordAuthenticationToken(principal, authentication.getCredentials(),
grantedAuthorityArray);
}
Run Code Online (Sandbox Code Playgroud)
登录jsp的基本部分如下所示:
<c:url value="/j_spring_security_check" var="formUrlSecurityCheck"/>
<form method="post" action="${formUrlSecurityCheck}">
<div id="errorArea" class="errorBox">
<c:if test="${not empty param.error}">
${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}
</c:if>
</div>
<label for="loginName">
Username: …Run Code Online (Sandbox Code Playgroud) 当我尝试搜索以vi中的斜杠/字符开头的字符串时,光标会跳转到上一次搜索的下一个搜索结果.但是,我想找到字面斜杠字符.如何才能做到这一点?
我在表格中有一个约束
CREATE TABLE "USERSAPPLICATIONS" (
"USERID" NUMBER NOT NULL ,
"APPLICATIONNAME" VARCHAR2 (30) NOT NULL ,
CONSTRAINT "PK_USERSAPPLICATIONS" PRIMARY KEY ("USERID","APPLICATIONNAME")
)
/
Run Code Online (Sandbox Code Playgroud)
两周前我修改了表,添加了一些列,删除了约束"PK_USERSAPPLICATIONS"并添加了一个代理键.我可以在Oracle SQL Developer中看到约束PK_USERSAPPLICATIONS不再存在.
无论如何,当我尝试使用相同的userid/applicationName组合添加两个条目时,我收到错误
SQL Error: ORA-00001: unique constraint (ACCOUNTMP1.PK_USERSAPPLICATIONS) violated
00001. 00000 - "unique constraint (%s.%s) violated"
*Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.
For Trusted Oracle configured in DBMS MAC mode, you may see
this message if a duplicate entry exists at a different level.
*Action: Either remove the unique …Run Code Online (Sandbox Code Playgroud) 我在样式表文件中为特定的HTML元素指定了样式,如下所示
label {
width: 200px;
color: red;
}
Run Code Online (Sandbox Code Playgroud)
在一个特例中,我想在HTML文档中使用label元素,但忽略为label元素指定的样式(仅适用于文档中的一个实例).有没有办法以通用的方式实现这一点而不用内联样式覆盖元素样式属性?
<label for="status">Open</label>
Run Code Online (Sandbox Code Playgroud)
重申一下,对于显示标签的HTML代码,应用了元素样式(宽度为200像素,红色).我希望使用默认样式属性(不知道它们是什么),而不必知道元素样式设置中具体指定的内容.
java ×3
spring-mvc ×2
sql ×2
autowired ×1
css ×1
editor ×1
escaping ×1
find ×1
html ×1
inheritance ×1
ip-address ×1
liferay ×1
logging ×1
ora-00001 ×1
oracle ×1
overriding ×1
php ×1
portal ×1
portlet ×1
qt-creator ×1
spring ×1
sql-server ×1
t-sql ×1
vi ×1
web-services ×1