基于Eclipse的spring+Apache+mysql的开发
来源:互联网 发布:买宠物的软件 编辑:程序博客网 时间:2024/06/09 23:10
1.新建spring工程后,在src里添加javabean的实现类代码,可以是任意功能的实现。
2.然后添加xml配置文件
内容格式(package.setting.xml):
<?xml version="1.0" encoding="UTF-8"?>
<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="beanid1"/*用于让应用程序访问class对应类的id标识*/ class="package1.classname1"/*对应src里的已经实现的类名*/>//需要访问的类设置
<property name="property1" value="value1"/>//对类中属性的设置,对应的类中必须要有setproperty1()函数的实现才能使用。
<property name="property2" value="value2"/>//功能如上,需要说明的是不管property是什么类型,value的值都需要使用引号。
</bean>
<bean id="beanid2" class="package2.classname2">
<property name="property1" value="value1"></property>
<property name="property2" value=" value2"></property>
</bean>
</beans>
3.应用程序的调用方式
package parent.here;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
public class classApp {
public static void main(String[] args) {
try{
BeanFactory factory=new XmlBeanFactory(new ClassPathResource("./package/setting.xml"));//注意引号里xml配置文件的路径要与2所述的xml文件的路径一致
classname1 instance1=(classname1 ) factory.getBean("beanid1");//classname1要是xml配置文件里beanid1对应类的名称
instance1.method1();//这里的method1必须是在classname1里已经实现的方法。
classname2instance2=(classname2) factory.getBean("beanid2");
instance2.method1();
instance2.method2();
}catch(Exception e)
{
System.out.print(e.toString());
}
}
}
4.然后运行应用程序就能得到预期的结果。
- 基于Eclipse的spring+Apache+mysql的开发
- 基于Eclipse的spring开发环境搭建
- Apache基于MySQL的身份验证
- Apache基于MySQL的身份验证
- 基于Eclipse的web开发实践之安装spring插件
- 基于 Eclipse 的 Apache Derby 工具
- webservice基于Spring的开发
- Spring 基于注解的开发
- 关于Eclipse中Spring框架开发遇到的 java.lang.NoClassDefFoundError: org/apache/juli/l问题
- 基于腾讯云的Centos6系统搭建Apache+Mysql+PHP开发环境
- windows7下的PHP+apache+mysql+eclipse for php 开发环境搭建
- windows7下的PHP+apache+mysql+eclipse for php 开发环境搭建
- Spring的基于AspectJ的AOP开发
- 基于mysql的spring cloud config server
- 初学Mybaties连接oracle/Mysql数据库 基于eclipse/myeclipse的开发环境
- 基于Eclipse的开发初识(一)
- 基于Eclipse开发OSGI的简单实例
- 搭建基于Eclipse的Jboss开发环境
- 第十二周项目三——用递归方法求解(1)
- JAVA多线程
- SCA 应用程序开发
- linux下安装oracle 11g
- Linux LB 集群知识、如何用 LVS 方式实现 LB 集群?**************************************
- 基于Eclipse的spring+Apache+mysql的开发
- iOS证书 ID 描述文件 (certificate id provisioning profile)
- 设计 4 个 ( 可以是 n 个 ) 线程,其中两个线程每次对 j 增加 1 ,另外两个线程对 j 每次减少 1
- Linux系统编程_7_进程环境之setjmp和longjmp函数
- FreeBSD上构架Nginx服务器
- 传智播客2014PHP基础就业班(28期)[高清完整版]附工具源码
- 需要时提升权限
- There is no getter for property named 'XXX' in 'class java.lang.String'
- Linux平台查看某个进程的线程