java吧 关注:1,293,995贴子:12,829,257

回复:ubuntu编程

只看楼主收藏回复

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="use" class="com.appform.Use">
<property name="g">
<ref local="job" />
</property>
</bean>
<bean id="job" class="com.appform.JobManager" />
</beans>
public interface GeneralInterface{
public void test();
}
public class JobManager implements GeneralInterface {
//把那个接口实现一下
public void test() {
System.out.println("test()");
}
public class Use implements MianInterface {
private GeneralInterface g;
//设值进来
public void setG(GeneralInterface g) {
this.g = g;
public void execute() {
g.test();
}
}
main 函数
Use p = (Use) ctx.getBean("use");
p.execute();
可以得到结果,假如我要是再有个类实现GeneralInterface接口
然后我要把两个类的 execute()方法都要执行,该怎么弄


IP属地:陕西18楼2014-06-24 15:35
收起回复
    给个简单粗暴的解决方法。把错误堆栈信息打印到某个文件,格式可以为
    yyyy-mm-dd:hh:mm:ss:error:xxxxxxxxxxxxxxx
    只要把错误信息打印到文件就行


    IP属地:陕西19楼2014-06-24 15:37
    收起回复
      2026-01-09 08:52:01
      广告
      不感兴趣
      开通SVIP免广告
      你们误会楼主了
      楼主说的开发三年 是指在学校开发了3年 不是工作了3年


      IP属地:湖北20楼2014-06-24 15:37
      收起回复
        大神用MyEclipse编几个入门的小程序会么,,,我想求你帮帮忙


        IP属地:河北21楼2014-06-24 15:40
        收起回复
          请问如何加薪


          IP属地:广东22楼2014-06-24 16:00
          回复
            eclipse连接数据库了,怎么查询数据库里的表,代码不会写!
            ackage kecheng;
            import java.sql.Connection;
            import java.sql.DriverManager;
            import java.sql.ResultSet;
            import java.sql.SQLException;
            import java.sql.Statement;
            public class stu {
            private static Statement statement;
            public static void main(String[] args) {
            System.out.println(login("admin","123456"));
            }
            public static boolean login(String name, String password){
            Connection connection=null;
            Statement statemrnt=null;
            ResultSet resultSet=null;
            try {
            Class.forName("com.mysql.jdbc.Driver");
            try {
            connection =DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?");
            statement = connection.createStatement();
            String sql="selcet count(id) from admin where name='"+name+"'and pwd'"+password+"'";
            System.out.println(sql);
            resultSet=statement.executeQuery(sql);
            resultSet.next();
            int count=resultSet.getInt(1);
            if(count!=0){
            return true;
            }
            } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            }
            } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            }
            return false;
            }
            }


            23楼2014-06-24 17:03
            收起回复
              想写一个用jdcb写的留言板系统。求教。感激不尽


              来自Android客户端24楼2014-06-24 23:24
              收起回复


                IP属地:广东来自Android客户端25楼2014-06-25 00:37
                回复
                  2026-01-09 08:46:01
                  广告
                  不感兴趣
                  开通SVIP免广告
                  做过ssh效率测试吗?我想知道效率慢主要慢在什么地方?怎末解决?


                  来自Android客户端26楼2014-06-25 08:24
                  回复
                    10年开发经验的怎么破……


                    来自Android客户端27楼2014-06-25 08:48
                    回复
                      http://tieba.baidu.com/p/3125907143楼主可以帮忙解决一下吗?


                      IP属地:内蒙古28楼2014-06-25 09:01
                      回复
                        你好,现在我想做个javaweb签到功能,表设计是怎么设计的。


                        IP属地:广东29楼2014-06-25 09:01
                        收起回复
                          三年的工作经验,足以解决新手的很多问题了.对于楼主乐于助人的精神,我表示必须得大赞.在软件编程,这个路途上,总会遇到很多的问题,像这种技术贴吧.就是缺楼主这种无私奉献的人.


                          IP属地:广东30楼2014-06-25 09:04
                          回复
                            大神,求救啊 关于获得泛型T的class对象的问题:
                            首先我声明了一个接口public interface BaseDal<T>,然后写了一个实现类public class EntityDal<T> implements BaseDal<T>。
                            在其中的一个方法,我需要用到T的class对象,于是我写了以下代码:
                            Type genType= this.getClass().getGenericInterfaces()[0];
                            ParameterizedType realType =(ParameterizedType)genType;
                            Type allTypes = realType.getActualTypeArguments();
                            Class<T> clazz = (Class<T>)allTypes[0];
                            在执行的时候,执行到最后一句就会报一个java.lang.ClassCastException: org.apache.harmony.luni.lang.reflect.ImplForVariable的错误,然后我打印一下相关信息,打印genType得到的BaseDal<T>,打印allTypes[0]输出的是T,打印allTypes[0].getClass输出的是org.apache.harmony.luni.lang.reflect.ImplForVariable,请问为什么allTypes[0]得到的类型不是Class类型的子类啊 ,问题出现在哪?应该怎么改啊 ?谢谢!


                            31楼2014-06-25 09:16
                            收起回复