使用netbeans搭建jsf+spring框架的方法

所属分类: 软件教程 / 编程开发 阅读数: 573
收藏 0 赞 0 分享

使用netbeans 搭建 JSF+SPRING 框架

spring版本使用4,jsf版本2.2

jsf的配置文件faces-config.xml


复制代码
代码如下:

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.0"
xmlns="<a href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a>"
xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"
xsi:schemaLocation="<a href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a> <a href="http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd</a>">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>

spring配置文件spring-config.xml


复制代码
代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a>"
xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"
xmlns:aop="<a href="http://www.springframework.org/schema/aop">http://www.springframework.org/schema/aop</a>"
xmlns:c="<a href="http://www.springframework.org/schema/c">http://www.springframework.org/schema/c</a>"
xmlns:context="<a href="http://www.springframework.org/schema/context">http://www.springframework.org/schema/context</a>"
xmlns:flow="<a href="http://www.springframework.org/schema/webflow-config">http://www.springframework.org/schema/webflow-config</a>"
xmlns:jee="<a href="http://www.springframework.org/schema/jee">http://www.springframework.org/schema/jee</a>"
xmlns:jms="<a href="http://www.springframework.org/schema/jms">http://www.springframework.org/schema/jms</a>"
xmlns:lang="<a href="http://www.springframework.org/schema/lang">http://www.springframework.org/schema/lang</a>"
xmlns:osgi="<a href="http://www.springframework.org/schema/osgi">http://www.springframework.org/schema/osgi</a>"
xmlns:p="<a href="http://www.springframework.org/schema/p">http://www.springframework.org/schema/p</a>"
xmlns:tx="<a href="http://www.springframework.org/schema/tx">http://www.springframework.org/schema/tx</a>"
xmlns:util="<a href="http://www.springframework.org/schema/util">http://www.springframework.org/schema/util</a>"
xmlns:jpa="<a href="http://www.springframework.org/schema/data/jpa">http://www.springframework.org/schema/data/jpa</a>"

xsi:schemaLocation="<a href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a> <a href="http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">http://www.springframework.org/schema/beans/spring-beans-4.0.xsd</a>
<a href="http://www.springframework.org/schema/aop">http://www.springframework.org/schema/aop</a> <a href="http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">http://www.springframework.org/schema/aop/spring-aop-4.0.xsd</a>
<a href="http://www.springframework.org/schema/context">http://www.springframework.org/schema/context</a> <a href="http://www.springframework.org/schema/context/spring-context-4.0.xsd">http://www.springframework.org/schema/context/spring-context-4.0.xsd</a>
<a href="http://www.springframework.org/schema/webflow-config">http://www.springframework.org/schema/webflow-config</a> <a href="http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd</a>
<a href="http://www.springframework.org/schema/jee">http://www.springframework.org/schema/jee</a> <a href="http://www.springframework.org/schema/jee/spring-jee-4.0.xsd">http://www.springframework.org/schema/jee/spring-jee-4.0.xsd</a>
<a href="http://www.springframework.org/schema/jms">http://www.springframework.org/schema/jms</a> <a href="http://www.springframework.org/schema/jms/spring-jms-4.0.xsd">http://www.springframework.org/schema/jms/spring-jms-4.0.xsd</a>
<a href="http://www.springframework.org/schema/lang">http://www.springframework.org/schema/lang</a> <a href="http://www.springframework.org/schema/lang/spring-lang-4.0.xsd">http://www.springframework.org/schema/lang/spring-lang-4.0.xsd</a>
<a href="http://www.springframework.org/schema/osgi">http://www.springframework.org/schema/osgi</a> <a href="http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd">http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd</a>
<a href="http://www.springframework.org/schema/tx">http://www.springframework.org/schema/tx</a> <a href="http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">http://www.springframework.org/schema/tx/spring-tx-4.0.xsd</a>
<a href="http://www.springframework.org/schema/util">http://www.springframework.org/schema/util</a> <a href="http://www.springframework.org/schema/util/spring-util-4.0.xsd">http://www.springframework.org/schema/util/spring-util-4.0.xsd</a>
<a href="http://www.springframework.org/schema/data/jpa">http://www.springframework.org/schema/data/jpa</a> <a href="http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">http://www.springframework.org/schema/data/jpa/spring-jpa.xsd</a>
">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
lazy-init="false">
<property name="locations">
<list>
<value>classpath*:jdbc.properties</value>
</list>
</property>
</bean>
<context:annotation-config/>
<context:component-scan base-package="cn.catr.lm.idc" />


<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!--不使用persistence.xml 做如下配置-->
<property name="packagesToScan" value="cn.catr.lm.idc.po"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.connection.driver_class">${jdbc.driverClassName}</prop>
<prop key="hibernate.connection.url">${jdbc.url}</prop>
<prop key="hibernate.connection.username">${jdbc.username}</prop>
<prop key="hibernate.connection.password">${jdbc.password}</prop>
<prop key="hibernate.c3p0.min_size">10</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>

<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<!-- 启用 annotation事务-->
<tx:annotation-driven transaction-manager="transactionManager"/>

</beans>

jdbc.properties文件


复制代码
代码如下:

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/idc
jdbc.username=root
jdbc.password=111111

更多精彩内容其他人还在看

scratch3.0怎么创建人物打篮球动画?

scratch3.0怎么创建人物打篮球动画?scratch3.0中想要创建一个动画效果,该怎么创建呢?下面我们就来看看scratch3.0制作人物打篮球动画的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

scratch3.0制作画随机多边形的小程序?

scratch3.0制作画随机多边形的小程序?scratch3.0中想要制作一个随机化多边形的小程序,该怎么实现根据输入的边数绘制多边形呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

IntelliJ IDEA 2020.1正式发布,你要的Almost都在这(推荐)

自从官方在2020-01-20发布了其2020年的Roadmap后,我便持续关注着、期待着JetBrains IntelliJ IDEA在“新10年”的首个版本的发布,感兴趣的朋友跟随小编一起看看吧
收藏 0 赞 0 分享

Visual Studio Code 1.44 解决中文代码显示乱码问题(小白图文教程)

这篇文章主要介绍了Visual Studio Code 1.44 解决中文代码显示乱码问题,文中通过图文介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
收藏 0 赞 0 分享

Advanced Installer 激活补丁使用教程 支持一键激活最新版本

MSI安装包制作工具 Advanced Installer 怎么免费使用?Advanced Installer激活补丁怎么能快速安装和激活呢?还有不知道的朋友一起详细了解下吧
收藏 0 赞 0 分享

scratch3.0变量和列表怎么控制花瓣数量?

scratch3.0变量和列表怎么控制花瓣数量?scratch3.0中制作花朵的时候,想要使用变量和列表来控制花瓣的数量,该怎么实现呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

scratch3.0怎么使用克隆命令控制旋转花瓣数?

scratch3.0怎么使用克隆命令控制旋转花瓣数?scratch3.0绘制花瓣的时候,想要实现输入数字实现绘制旋转花瓣的数量,下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

Navicat for MySQL v15中文企业版安装激活教程(附下载)

Navicat for MySQL 15是一款第三方mysql管理工具,能够同时连接 MySQL 和 MariaDB 数据库,这里带来了Navicat for MySQL 15企业版的安装激活方法,并附注册机下载
收藏 0 赞 0 分享

scratch3.0怎么创建人物跳舞的小程序?

scratch3.0怎么创建人物跳舞的小程序?scratch3.0中想要创建一个小动画,该怎么制作一个人物跳舞的小动画呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

notepad++默认单实例怎么修改? Notepad++多实例运行的技巧

notepad++默认单实例怎么修改?notepad++默认单实例,但是多实例可以同时开多个独立的Notepad窗口,下面就来看看Notepad++多实例运行的技巧,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多