• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

地对地导弹(地对地导弹)模板参考

pom.xml

?可扩展标记语言版本='1.0 '编码='UTF八号'?

项目xmlns=' http://maven。阿帕奇。org/POM/4。0 .0 '

xmlns : xsi=' http://www。w3。' org/2001/XML架构-实例'

xsi :架构位置=' http://maven。阿帕奇。org/POM/4。0 .0 http://maven.apache.org/xsd/maven-4.0.0.xsd'

型号版本4 .0 .0/型号版本

groupIdcom.lee/groupId

artifactIdssmbuild/artifactId

1.0版-快照/版本

性能

maven.compiler.source8/maven。编译器。来源

玛文。编译器。目标8/maven。编译器。目标

/属性

!-导入依赖-

!-数据库驱动连接池servlet JSP mybatis mybatis-spring spring Junit

属国

!- mysql驱动-

属国

groupIdmysql/groupId

artifactId MySQL-连接器-java/artifactId

版本8 .0 .28/版本

/依赖关系

!-数据库连接池c3p0 -

属国

groupIdcom.mchange/groupId

artifactIdc3p0/artifactId

版本0 .9 .5 .5/版本

/依赖关系

!- servlet -

属国

groupIdjavax.servlet/groupId

artifact id servlet-API/artifact id

版本2.5/版本

/依赖关系

!- jsp -

属国

groupIdjavax.servlet.jsp/groupId

artifactIdjsp-api/artifactId

版本2.2/版本

/依赖关系

!- jstl -

属国

groupIdjavax.servlet/groupId

artifactIdjstl/artifactId

版本1.2/版本

/依赖关系

!-我的巴蒂斯-

属国

groupIdorg.mybatis/groupId

人工智能

actId>mybatis</artifactId> <version>3.5.7</version> </dependency> <!-- mybatis-spring --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>2.0.6</version> </dependency> <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.3.13</version> </dependency> <!-- spring-jdbc --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.3.18</version> </dependency> <!-- junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <!-- lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.22</version> </dependency> </dependencies> <!-- 静态资源导出问题 --> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> </resources> </build> </project>

mybatis-config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<!-- 核心配置文件 -->
<configuration>
    <!--  配置数据源,交给 Spring 去做  -->
    <!--  日志功能  -->
    <settings>
        <setting name="logImpl" value="STDOUT_LOGGING"/>
    </settings>
    <typeAliases>
        <package name="com.lee.pojo"/>
    </typeAliases>
    <!--  可以被 spring-dao 中的配置所取代  -->
<!--    <mappers>-->
<!--        <mapper class="com.lee.dao.BookMapper"/>-->
<!--    </mappers>-->
</configuration>

database.properties

# c3p0
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf8
jdbc.username=root
jdbc.password=ll546546
# spring jdbc
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/ssmbuild?useSSL=true&useUnicode=true&serverTimezone=Asia/Shanghai&characterEncoding=utf8
username=root
password=ll546546

applicationContext.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.xsd">
    <!--总的 spring 配置包 -->
    <import resource="classpath:spring-dao.xml"/>
    <import resource="classpath:spring-service.xml"/>
    <import resource="classpath:springmvc-servlet.xml"/>
</beans>

spring-dao.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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
    <!-- spring数据库 配置 -->
<!--    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">-->
<!--        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>-->
<!--        <property name="url" value="jdbc:mysql://localhost:3306/ssmbuild?useSSL=false&amp;-->
<!--                                useUnicode=true&amp;serverTimezone=Asia/Shanghai&amp;characterEncoding=utf8"/>-->
<!--        <property name="username" value="root"/>-->
<!--        <property name="password" value="ll546546"/>-->
<!--    </bean>-->
    <!--  1. 关联数据库配置文件  -->
    <context:property-placeholder location="classpath:database.properties"/>
    <!--  2. 连接池  -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driver}"/>
        <property name="jdbcUrl" value="${jdbc.url}"/>
        <property name="user" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <!--  c3p0 连接池的私有属性  -->
        <property name="maxPoolSize" value="30"/>
        <property name="minPoolSize" value="10"/>
        <!--  关闭连接后不自动commit  -->
        <property name="autoCommitOnClose" value="false"/>
        <!--  获取连接超时时间  -->
        <property name="checkoutTimeout" value="10000"/>
        <!--  当获取连接失败重试次数  -->
        <property name="acquireRetryAttempts" value="2"/>
    </bean>
    <!--  3. SqlSessionFactory  -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <!--  绑定 mybatis配置文件  -->
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
    </bean>
    <!--  4. 配置 dao接口扫描包,动态的实现了 dao 接口可以注入到 Spring 容器中   -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <!--  注入 SQLSessionFactory  -->
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
        <!--  要扫描的包  -->
        <property name="basePackage" value="com.lee.dao"/>      <!-- 替代 mapper 映射 -->
    </bean>
</beans>

spring-service.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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
    <!--  1. 扫描 service 下的包  -->
    <context:component-scan base-package="com.lee.service"/>    <!-- BookServiceImpl 添加 @Service 就可以扫描到  -->
    <!--  2.  将所有的业务类注入到 Spring , 可以通过配置 或者注解实现  -->
    <bean id="bookServiceImpl" class="com.lee.service.BookServiceImpl">
<!--    <bean id="bookServiceImpl" class="com.lee.service.BookServiceImpl">-->
        <property name="bookMapper" ref="bookMapper"/>
    </bean>
    <!--  3. 声明式事务配置  -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <!--  注入数据源  -->
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--  4. aop 事务支持  -->
</beans>

springmvc-servlet.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:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
    <!--  1. 注解驱动  -->
    <mvc:annotation-driven/>
    <!--  2. 静态资源过滤  -->
    <mvc:default-servlet-handler/>
    <!--  3. 扫描包 controller -->
    <context:component-scan base-package="com.lee.controller"/>
    <!--  4. 视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="internalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <!--  DispatcherServlet  -->
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <!--  乱码过滤  -->
    <filter>
        <filter-name>encoding</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>utf-8</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encoding</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!--  session  -->
    <session-config>
        <session-timeout>15</session-timeout>
    </session-config>
</web-app>
Link to comment
Share on other sites