? java亚博足球娱乐场注册--任意三数字加yabo.com直达官网之利用idea创建一个基本的smm项目(带增删 亚博足球娱乐场注册,亚博娱乐全天彩,亚博官网赢钱不给
VB.net 2010 视频亚博足球娱乐场注册--任意三数字加yabo.com直达官网 VB.net 2010 视频亚博足球娱乐场注册--任意三数字加yabo.com直达官网 VB.net 2010 视频亚博足球娱乐场注册--任意三数字加yabo.com直达官网
SQL Server 2008 视频亚博足球娱乐场注册--任意三数字加yabo.com直达官网 c#入门经典亚博足球娱乐场注册--任意三数字加yabo.com直达官网 Visual Basic从门到精通视频亚博足球娱乐场注册--任意三数字加yabo.com直达官网
  • java亚博足球娱乐场注册--任意三数字加yabo.com直达官网之利用idea创建一个基本的smm项目(带增删

  • 2019-06-10 22:44 来源:未知

环境? idea? jdk1.8? tomcat? mysql

打开idea选择创建一个maven项目

然后点击next,next,finsh

然后看项目的结构

如图所示

接着创建com包,再在com包下新建四个包,分别命名为:

?

自定义pom.xml

复制代码
xml version="1.0" encoding="UTF-8"?>

<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.0modelVersion>

 <groupId>com.ligroupId>
 <artifactId>ssm_test_2artifactId>
 <version>1.0-SNAPSHOTversion>
 <packaging>warpackaging>

 <name>ssm_test_2 Maven Webappname>
 
 <properties>
   <srping.version>4.0.2.RELEASEsrping.version>
   <mybatis.version>3.2.8mybatis.version>
   <slf4j.version>1.7.12slf4j.version>
   <log4j.version>1.2.17log4j.version>
   <druid.version>1.0.9druid.version>
 properties>
 
 <dependencies>
   
   <dependency>
     <groupId>javax.servletgroupId>
     <artifactId>javax.servlet-apiartifactId>
   dependency>
   

   
   <dependency>
     <groupId>javax.servlet.jspgroupId>
     <artifactId>javax.servlet.jsp-apiartifactId>
     <version>2.3.1version>
   dependency>
   
   <dependency>
     <groupId>junitgroupId>
     <artifactId>junitartifactId>
     <version>4.11version>
     
     <scope>testscope>
   dependency>

   
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-testartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-coreartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-oxmartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-txartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-jdbcartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-aopartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-contextartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-context-supportartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-expressionartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-ormartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-webartifactId>
     <version>${srping.version}version>
   dependency>
   <dependency>
     <groupId>org.springframeworkgroupId>
     <artifactId>spring-webmvcartifactId>
     <version>${srping.version}version>
   dependency>
   
   
   <dependency>
     <groupId>org.mybatisgroupId>
     <artifactId>mybatisartifactId>
     <version>${mybatis.version}version>
   dependency>
   <dependency>
     <groupId>org.mybatisgroupId>
     <artifactId>mybatis-springartifactId>
     <version>1.2.2version>
   dependency>
   
   
   <dependency>
     <groupId>mysqlgroupId>
     <artifactId>mysql-connector-javaartifactId>
     <version>5.1.35version>
   dependency>
   
   <dependency>
     <groupId>commons-dbcpgroupId>
     <artifactId>commons-dbcpartifactId>
     <version>1.2.2version>
   dependency>
   
   <dependency>
     <groupId>jstlgroupId>
     <artifactId>jstlartifactId>
     <version>1.2version>
   dependency>
   
   <dependency>
     <groupId>log4jgroupId>
     <artifactId>log4jartifactId>
     <version>${log4j.version}version>
   dependency>
   <dependency>
     <groupId>org.slf4jgroupId>
     <artifactId>slf4j-apiartifactId>
     <version>${slf4j.version}version>
   dependency>
   <dependency>
     <groupId>org.slf4jgroupId>
     <artifactId>slf4j-log4j12artifactId>
     <version>${slf4j.version}version>
   dependency>
   
   <dependency>
     <groupId>com.alibabagroupId>
     <artifactId>druidartifactId>
     <version>${druid.version}version>
   dependency>
 dependencies>

 <build>
   
   <resources>
     <resource>
       <directory>src/main/javadirectory>
       <includes>
         <include>**/*.propertiesinclude>
         <include>**/*.xmlinclude>
       includes>
       <filtering>falsefiltering>
     resource>
     <resource>
       <directory>src/main/resourcesdirectory>
       <includes>
         <include>**/*.propertiesinclude>
         <include>**/*.xmlinclude>
       includes>
       <filtering>falsefiltering>
     resource>
   resources>
   
   <plugins>
     <plugin>
       <groupId>org.apache.maven.pluginsgroupId>
       <artifactId>maven-compiler-pluginartifactId>
       <version>3.2version>
       <configuration>
         <source>1.8source>
         <target>1.8target>
         <encoding>UTF-8encoding>
       configuration>
     plugin>
   plugins>
 build>
project>
复制代码

在resource包下新建Directory:mapper(用来放xxMapper.xml)

添加jdbc.properties和lo4j.properties文件

jdbc.properties

复制代码
driver=com.mysql.jdbc.Driver
url=jdbc\:mysql\://localhost\:3306/test
username=root
password=123456

initialSize=0

maxActive=20

maxIdle=20

minIdle=1

maxWait=60000
复制代码

lo4j.properties文件

复制代码
log4j.rootLogger=DEBUG,CONSOLE,file
#log4j.rootLogger=ERROR,ROLLING_FILE
log4j.logger.com.qhit.dao=debug
log4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=debug
log4j.logger.java.sql.ResultSet=debug
log4j.logger.org.tuckey.web.filters.urlrewrite.UrlRewriteFilter=debug

######################################################################################
# Console Appender  日志在控制输出配置
######################################################################################
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.Threshold=error
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern= [%p] %d %c - %m%n


######################################################################################
# DailyRolling File  每天产生一个日志文件,文件名格式:log2009-09-11
######################################################################################
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern=yyyy-MM-dd
log4j.appender.file.File=log.log
log4j.appender.file.Append=true
log4j.appender.file.Threshold=error
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-M-d HH:mm:ss}%x[%5p](%F:%L) %m%n


log4j.logger.com.opensymphony.xwork2=error  
复制代码

?

然后创建applicationContext.xm

复制代码
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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
                       http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
                       http://www.springframework.org/schema/tx
                       http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

  
  <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="location" value="classpath:jdbc.properties"/>
  bean>

  
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
     <property name="driverClassName" value="${driver}"/>
     <property name="url" value="${url}"/>
     <property name="username" value="${username}"/>
     <property name="password" value="${password}"/>
  bean>

  
  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
     <property name="dataSource" ref="dataSource"/>
     
     <property name="typeAliasesPackage" value="com.lwy.pojo"/>
     
     <property name="mapperLocations" value="classpath:mapper/*.xml"/>
  bean>

  
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
     
     <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
     
     <property name="basePackage" value="com.lwy.mapper"/>
  bean>

  
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
     
     <property name="dataSource" ref="dataSource"/>
  bean>
beans>
复制代码

创建sping-mvc.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"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/mvc
      http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

  
  <context:component-scan base-package="com.lwy"/>

  
  <mvc:annotation-driven/>

  
  <mvc:default-servlet-handler/>

  
  <bean class