javaee_SSH
生活随笔
收集整理的這篇文章主要介紹了
javaee_SSH
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
這是javaee課程的第六個(gè)實(shí)驗(yàn)ssh sturts2+sping 3+hibernate
現(xiàn)予以記錄整個(gè)過(guò)程,以防遺忘
1.
?
2.
3.
4.
5.輸入mvnrepository.com進(jìn)入->搜索spring—>點(diǎn)擊spring core
6.
pom.xml里面的內(nèi)容可以在上面的官網(wǎng)上面索取,我下面給出我我們老師給我們配的一個(gè),我就直接使用了,一般是沒(méi)什么問(wèn)題,
有卻什么,再到這個(gè)官網(wǎng)上面進(jìn)行尋找
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>testsshmaven</groupId><artifactId>testsshmaven</artifactId><version>0.0.1-SNAPSHOT</version><properties><spring.version>4.3.14.RELEASE</spring.version><struts.version>2.5.16</struts.version></properties><dependencies><!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api --><dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version><scope>provided</scope></dependency><!-- https://mvnrepository.com/artifact/org.eclipse.persistence/javax.persistence --> <dependency><groupId>org.eclipse.persistence</groupId><artifactId>javax.persistence</artifactId><version>2.2.0</version> </dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-core --> <dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>${spring.version}</version> </dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-beans --><dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId><version>${spring.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-context --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-web --><dependency><groupId>org.springframework</groupId><artifactId>spring-web</artifactId><version>${spring.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>${spring.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc --><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>${spring.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.springframework/spring-orm --><dependency><groupId>org.springframework</groupId><artifactId>spring-orm</artifactId><version>${spring.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core --><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>5.2.16.Final</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-core --><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-core</artifactId><version>${struts.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-spring-plugin --><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-spring-plugin</artifactId><version>${struts.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-convention-plugin --><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-convention-plugin</artifactId><version>${struts.version}</version></dependency><!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>6.0.6</version></dependency><!-- https://mvnrepository.com/artifact/commons-dbcp/commons-dbcp --><dependency><groupId>commons-dbcp</groupId><artifactId>commons-dbcp</artifactId><version>1.4</version></dependency></dependencies> </project>7.接下來(lái),配置struts.xml,注意,放在main->resource
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <!-- 注意:編程或運(yùn)行時(shí)要聯(lián)網(wǎng) --> <struts><constant name="struts.i18n.encoding" value="utf-8"/><constant name="struts.convention.action.packages" value="action"/><constant name="struts.enable.DynamicMethodInvocation" value="true" /><!-- <global-allowed-methods>*</global-allowed-methods> --> <!-- <package name="test" namespace="/" extends="struts-default"><global-allowed-methods>*</global-allowed-methods></package> --> </struts>?
?8.配置spring.xml??注意,放在main->resource
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.3.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsd"><!-- 引入properties --><context:property-placeholder location="classpath:database.properties"/><!-- 開(kāi)啟包掃描,并注冊(cè)注解,掃描@Service,@Controller,@Repository,.... --><context:component-scan base-package="action,lib"/><!-- 配置數(shù)據(jù)源 --><bean id="dataSource"class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName" value="${jdbc.driver}"></property><property name="url" value="${jdbc.url}"></property><property name="username" value="${jdbc.user}"></property><property name="password" value="${jdbc.password}"></property></bean><!-- 配置hibernate sessionfactory --><bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"><property name="dataSource"><ref bean="dataSource" /></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">${hibernate.dialect}</prop><prop key="hibernate.show_sql">${hibernate.show_sql}</prop><prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop></props></property><property name="mappingResources"><list><!-- <value>lib/Account.hbm.xml</value> --></list></property><!-- Scan entities automatically 自動(dòng)掃描實(shí)體類Entity --><property name="packagesToScan" value="lib"/></bean></beans>9.注解映射實(shí)體和表:https://www.cnblogs.com/liuconglin/p/6096174.html
10.
轉(zhuǎn)載于:https://www.cnblogs.com/zwz178/p/9114967.html
總結(jié)
以上是生活随笔為你收集整理的javaee_SSH的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: ESP系列AT指令开发笔记
- 下一篇: Java核心知识点 --- 线程中如何创