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

所属分类: 软件教程 / 编程开发 阅读数: 604
收藏 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

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

PowerDesigner16.6怎么破解?SAP PowerDesigner16.6安装破解详细图文教程

PowerDesigner是一款来自国外的数据库建模工具,最近,很多网友问小编PowerDesigner16.6怎么破解?今天脚本之家小编就给大家带来SAP PowerDesigner16.6安装破解详细图文教程,希望对大家有所帮助
收藏 0 赞 0 分享

WebStorm 2017.3最新汉化激活破解及安装教程(附汉化包+原版下载)

WebStorm 2017中文破解版是一款JavaScript开发工具,是最强大的HTML5编辑器以及最智能的JavaSscript IDE,下面就整理WebStorm 2017.3最新汉化破解教程,并附有汉化包及官方原版程序下载地址
收藏 0 赞 0 分享

PhpStorm 10.0.2怎么激活?PhpStorm 10.0.2激活破解图文教程(附注册码)

PhpStorm 10.0.2怎么激活?对于新手来说最头痛的问题还是激活和使破解的问题,今天脚本之家小编就给大家带来PhpStorm 10.0.2激活破解图文教程(附注册码),希望对大家有所帮助
收藏 0 赞 0 分享

Toad for Oracle 2017完整破解版安装教程(附注册码) 64位

Toad for oracle 2017是一款功能强大的数据库管理软件,支持敏捷数据库开发工作,是一个功能强大、结构紧凑的专业化PL/SQL开发环境,本文提供最新版的Toad for Oracle 2017详细的安装步骤,以及软件下载地址和注册码
收藏 0 赞 0 分享

Aqua Data Studio 18汉化安装破解教程(附DateStopper破解下载)

Aqua Data Studio18中文版是一套完整IDE的数据库开发工具,新版对其通用数据库管理和分析软件的一次重大升级,下面就带来了Aqua Data Studio18最新版详细安装步骤,以及破解方法,仅供参考
收藏 0 赞 0 分享

informatica powercenter 9.x安装与配置图文详细教程(适应于Windows系统)

informatica powercenter是一款使用相当广泛的数据集成平台(ETL工具),本文主要针对目前还不会安装与配置informatica powercenter 9.x程序的朋友们,来图文详细介绍informatica powercenter 9.x安装与配置教程,并
收藏 0 赞 0 分享

Myeclipse 2017 CI8汉化破解教程(附注册激活码)

MyEclipse可用于用户所有的UML, AJAX, Web, Web Services, J2EE, JSP, XML, Struts, JSF, Java Persistence, EJB,扩展数据库支持以及应用程序服务器集成需求,那么Myeclipse 2017 CI8怎
收藏 0 赞 0 分享

CoolFormat 源代码格式化工具使用帮助手册

CoolFormat源代码格式化是一款C\C++\C#\CSS\HTML\Java\JavaScript\JSON\Objective-C\PHP\SQL\XML代码格式化工具。软件可以快速多种风格格式化,并对语言进行着色。界面采用Office 2010风格,并有多种样式可以替换
收藏 0 赞 0 分享

Sublime Text 3怎么设配置浏览默认路径为localhost?

Sublime Text 3怎么设置浏览器打开就是localhost路径?Sublime Text 3编辑程序的时候,需要对代码进行预览,该怎么制定配置浏览器默认的浏览路径为localhost呢?下面我们就来看看详细的教程,需要的朋友可以参考下
收藏 0 赞 0 分享

Visual Studio窗口界面显示黑色很多功能消失了怎么办?

Visual Studio窗口界面显示黑色很多功能消失了怎么办?Visual Studio打开以后,窗口变成黑色的了,新建文件的时候,发现工具栏中少了很多功能,该怎么办呢?下面我们就来看看详细的解决办法,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多