我正在使用Spring 3.1并使用@Configuration和@ComponentScan属性引导应用程序.
实际开始是完成的
new AnnotationConfigApplicationContext(MyRootConfigurationClass.class);
Run Code Online (Sandbox Code Playgroud)
此Configuration类使用注释
@Configuration
@ComponentScan("com.my.package")
public class MyRootConfigurationClass
Run Code Online (Sandbox Code Playgroud)
这很好用.但是我想更具体地说明我扫描的软件包,所以我试过了.
@Configuration
@ComponentScan("com.my.package.first,com.my.package.second")
public class MyRootConfigurationClass
Run Code Online (Sandbox Code Playgroud)
但是,这会失败,并告诉我无法找到使用@Component注释指定的组件.
做我正在做的事情的正确方法是什么?
谢谢
我们正在使用上限并使用一个脚本将USR2发送到unicorn进程进行重新加载,它通常可以正常工作,但每隔一段时间它就会失败.当发生这种情况时,查看unicorn日志显示它正在寻找旧版本目录中不再存在的Gemfile.
例外:
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/definition.rb:14:in `build': /var/www/railsapps/inventory/releases/20111128233407/Gemfile not found (Bundler::GemfileNotFound)
Run Code Online (Sandbox Code Playgroud)
澄清那不是当前的版本,而是一个旧版本已被删除.
当它工作时它似乎工作正常 - 即它确实拾取新代码 - 所以我不认为它在某种程度上卡在旧版本.
有任何想法吗?
我有一个模特
class Anh_chi_tiet(models.Model):
du_an = models.ForeignKey(Du_an)
title = models.CharField(max_length=120)
url = models.ImageField(upload_to='images', height_field='50', width_field='100')
url_detail = models.ImageField(upload_to='images', height_field='200', width_field='400')
Run Code Online (Sandbox Code Playgroud)
我总是收到这个错误:
'Anh_chi_tiet' object has no attribute '100'
Run Code Online (Sandbox Code Playgroud)
似乎Django需要同一个表Anh_chi_tiet中的两个字段来保存height_field和width_field.
如何在不添加表格中的新字段的情况下直接设置这些值?
我正在使用Struts2.我有一个对话框,其中包含通过"search_users"操作更新的人员列表.在此列表旁边,我有一个表单,您可以在提交表单时通过调用"add_user"操作来添加另一个人.
我要做的是,一旦执行了add_user操作,就会使用"search_user"操作更新列表.
我尝试在struts.xml中使用结果类型"redirect",如下所示:
<action name="search_users" class="org.apache.struts.gestion_edt.controller.adm_proyectos.BLSubequipo" method="searchUsers">
<result name="success">list.jsp</result>
</action>
<action name="add_user" class="org.apache.struts.gestion_edt.controller.adm_proyectos.BLTipoEntregable" method="addUser">
<result name="success" type="redirectAction">search_users</result>
</action>
Run Code Online (Sandbox Code Playgroud)
但这不起作用.我究竟做错了什么?有什么东西我应该添加到我不知道的struts.xml文件中吗?
这是我得到的错误消息:
"Caused by: There is no result type defined for type 'redirect-action' mapped with name 'success'. Did you mean 'redirectAction'? - result - file:/.../struts.xml:59:44
at ..."
Run Code Online (Sandbox Code Playgroud) 我在sun solaris 中托管的weblogic server 10g 中的 xml 转换中收到以下 java stackoverflow 错误。这仅发生在特定的 xml 转换中,其余所有 xml 转换都可以正常工作。使用的 xsl 文件也不是很大。
我正在使用 rt.jar 中提供的 Transformation api,但是从com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl我没有打包到我的应用程序中的xalan apache package( )得到这个错误。
另一个有趣的事情是,当我在 Windows 机器上托管的 weblogic 10g 服务器中运行应用程序时,我没有得到这个异常,我只在 sun solaris 中得到这个。
任何人都可以让我知道为什么我会收到此错误。
你能告诉我是哪个 jar 文件导致了异常吗?weblogic 会有 xalan.jar 吗?如果是这样,我可以尝试升级 jar 文件,看看它是否有效?
Caused by: java.lang.StackOverflowError
at com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.characters(SimpleResultTreeImpl.java)
at com.sun.org.apache.xalan.internal.xsltc.dom.SimpleResultTreeImpl.copy(SimpleResultTreeImpl.java:438)
at com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary.copy(BasisLibrary.java:1317)
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace()
at GregorSamsa.replace() …Run Code Online (Sandbox Code Playgroud) 我有一些关于界面使用的一般问题:
例如 :
public interface Animal {
public getVoice();
public String getName();
}
public class Dog implements Animal {
private String name;
public getVoice(){
System.out.println("Brrr");
}
public String getName(){
return this.name;
}
public void setName(String name){
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个我正面临的设计问题,我把它带到这里,所以也许我可以得到更多的想法.
目前在我的项目中,我有一个场景,我需要代表孩子的年龄.
年龄可以从0到15岁.从1岁到15岁很容易,我可以将它存储为整数,但问题是如果年龄介于0和1之间.那么我想将它存储在几个月内.
将年龄存储为java.util.Date无效将因为我不想与当前日期进行比较(我正在处理一个非常大的数据库).关于浮点数,你知道一年有12个月,所以我需要翻译0.5到6个月和0.7我不知道...
我正在寻找一种将年龄存储在一种类型中的好方法.它可以是Enum等等.它应该尽可能小.并且应该可以将类型保留在数据库中而不会出现任何问题......
以上是本网站的观点 http://blog.ibeesolutions.com/web-services-implementation-considerations.html
从Web服务的性能角度来看,序列化是一个重要问题,因为Web服务在SOAP消息中使用XML.
因此减少序列化 XmlIgnore
要在对象传递到Web方法或从Web方法传递对象时限制对象公开的字段,并减少通过线路发送的数据量,XmlIgnore应使用该属性,如下所示.
该XmlSerializer班将忽略该属性标注的任何领域.
请注意,XmlIgnore与从IFormatter接口派生的格式化程序不同,仅序列化公共成员.
// This is the class that will be serialized.
public class MyClass
{
// The str1 value will be serialized.
public string str1;
/* This field will be ignored when serialized–
unless it’s overridden. */
[XmlIgnoreAttribute]
public string str2;
}
Run Code Online (Sandbox Code Playgroud)
在这里,作者提到了有关Inproving Webservices的提示,其中就是使用XmlIgnoreAttribute
我通过Apache CXF Framework开发了一个使用Java的Web服务.
请告诉我如何在Java技术中使用它或任何类似的属性?
我试图在tomcat中使用池进行数据库连接,这就是我的上下文:
<Resource name="jdbc/slingemp" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="root" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/slingemp"/>
Run Code Online (Sandbox Code Playgroud)
这就是我的web.xml:
<description>MySQL JNDI Test</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/slingemp</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Run Code Online (Sandbox Code Playgroud)
这就是我与数据库连接的方式:
package org.slingemp.jnditest;
import java.io.IOException;
import java.sql.Connection;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.tomcat.jdbc.pool.DataSource;
/**
* Servlet implementation class JNDILookUpServlet
*/
@WebServlet("/JNDILookUpServlet")
public class JNDILookUpServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public JNDILookUpServlet() {
super();
// TODO Auto-generated constructor …Run Code Online (Sandbox Code Playgroud) 我已经尝试使用 Axis2Code 生成器和 Xfire 从 WSDL 生成 javasource 代码,但它无法连接(声明连接被拒绝),SOAPUI 也是如此。
但我可以在浏览器中浏览相同的 WSDL。
是否有其他 API 可以帮助从 WSDL 生成代码?
请建议
我有一个从java bean获取值的xhtml页面:
<h:dataTable value="${myBean.getAccounts}" var="account">
<h:column>
<f:facet name="header">Account ID</f:facet>
#{account.id}
</h:column>
<h:column>
<f:facet name="header">Account Name</f:facet>
#{account.name}
</h:column>
</h:dataTable>
Run Code Online (Sandbox Code Playgroud)
问题是,当我在Tomcat 7服务器上运行它时,我收到一个错误:getAccounts不是myBean属性.java类的getAccounts方法是一个返回一些结果的独立方法.
我无法调用此方法吗?
任何帮助表示赞赏.
谢谢!
class History {
public String[] history;
public History(String[] history) {
if (history == null)
history = new String[]{};
else
history = this.history
}
}
Run Code Online (Sandbox Code Playgroud)
无论我给它什么,它只是一直保存null ...所以无法使用它..
如果我想从另一个类调用一个类的多个方法,我可以通过仅使用'new classname()'而不在类引用中捕获它来调用它们吗?
public class Example {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new pqr().a=5;
new pqr().b=10;
new pqr().display();
}
}
class pqr
{
int a,b;
public void display()
{
System.out.println(a+" "+b);
}
}
Run Code Online (Sandbox Code Playgroud)