SpringBoot 配置文件及jar包

[html] view plain copy
  1. spring.xml文件  
[html] view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3. <span style="white-space:pre;"> </span>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4. <span style="white-space:pre;"> </span>xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"  
  5. <span style="white-space:pre;"> </span>xsi:schemaLocation="  
  6. <span style="white-space:pre;"> </span>http://www.springframework.org/schema/beans   
  7. <span style="white-space:pre;"> </span>http://www.springframework.org/schema/beans/spring-beans.xsd   
  8. <span style="white-space:pre;"> </span>http://www.springframework.org/schema/context   
  9. <span style="white-space:pre;"> </span>http://www.springframework.org/schema/context/spring-context.xsd  
  10. <span style="white-space:pre;"> </span>http://www.springframework.org/schema/tx   
  11. <span style="white-space:pre;"> </span>http://www.springframework.org/schema/tx/spring-tx.xsd  
  12. <span style="white-space:pre;"> </span>http://www.springframework.org/schema/aop   
  13. <span style="white-space:pre;"> </span>http://www.springframework.org/schema/aop/spring-aop.xsd  
  14. <span style="white-space:pre;"> </span>">  
  15. <span style="white-space:pre;"> </span>  
  16. <span style="white-space:pre;"> </span><bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">  
  17. <span style="white-space:pre;">     </span><property name="driverClassName" value="com.mysql.jdbc.Driver"></property>  
  18. <span style="white-space:pre;">     </span><property name="url" value="jdbc:mysql://127.0.0.1:3306/springboot"></property>  
  19. <span style="white-space:pre;">     </span><property name="username" value="root"></property>  
  20. <span style="white-space:pre;">     </span><property name="password" value="root"></property>  
  21. <span style="white-space:pre;"> </span></bean>  
  22.   
  23.   
  24. <span style="white-space:pre;"> </span><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
  25. <span style="white-space:pre;">     </span><property name="dataSource" ref="dataSource" />  
  26. <span style="white-space:pre;">     </span><property name="mapperLocations" value="classpath:com/xinxin/mapper/*.xml"></property>  
  27. <span style="white-space:pre;"> </span></bean>  
  28.   
  29.   
  30. <span style="white-space:pre;"> </span><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
  31. <span style="white-space:pre;">     </span><property name="basePackage" value="com.xinxin.mapper" />  
  32. <span style="white-space:pre;">     </span><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>  
  33. <span style="white-space:pre;"> </span></bean>  
  34.   
  35.   
  36. </beans>  
[html] view plain copy
  1. springMVC.xml文件  
[html] view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.     xmlns:mvc="http://www.springframework.org/schema/mvc"  
  5.     xsi:schemaLocation="  
  6.     http://www.springframework.org/schema/beans   
  7.     http://www.springframework.org/schema/beans/spring-beans.xsd   
  8.     http://www.springframework.org/schema/context   
  9.     http://www.springframework.org/schema/context/spring-context.xsd  
  10.     http://www.springframework.org/schema/mvc    
  11.     http://www.springframework.org/schema/mvc/spring-mvc.xsd  
  12.     ">  
  13.       
  14.     <context:component-scan base-package="com.xinxin"></context:component-scan>  
  15.     <mvc:annotation-driven />  
  16.       
  17. </beans>  
[html] view plain copy
  1. application.properties  
[html] view plain copy
  1. spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8  
  2. spring.datasource.username=root  
  3. spring.datasource.password=root  
  4. spring.mvc.view.prefix=/jsp/  
  5. spring.mvc.view.suffix=.jsp  
  6. logging.level.com.bw.dao=debug  
  7.   
  8. mybatis.mapper-locations=classpath:com/xinxin/mapper/*.xml  
[html] view plain copy
  1. pom.xml  
[html] view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3.     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
  4.     <modelVersion>4.0.0</modelVersion>  
  5.   
  6.     <groupId>com.xinxin</groupId>  
  7.     <artifactId>xinxin</artifactId>  
  8.     <version>0.0.1-SNAPSHOT</version>  
  9.     <packaging>war</packaging>  
  10.   
  11.     <name>shengchengqi</name>  
  12.     <description>Demo project for Spring Boot</description>  
  13.   
  14.     <parent>  
  15.         <groupId>org.springframework.boot</groupId>  
  16.         <artifactId>spring-boot-starter-parent</artifactId>  
  17.         <version>2.0.1.RELEASE</version>  
  18.         <relativePath/> <!-- lookup parent from repository -->  
  19.     </parent>  
  20.       
  21.     <properties>  
  22.         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
  23.         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>  
  24.         <java.version>1.8</java.version>  
  25.     </properties>  
  26.   
  27.     <dependencies>  
  28.         <dependency>  
  29.             <groupId>org.springframework.boot</groupId>  
  30.             <artifactId>spring-boot-starter-web</artifactId>  
  31.         </dependency>  
  32.         <dependency>  
  33.             <groupId>org.mybatis.spring.boot</groupId>  
  34.             <artifactId>mybatis-spring-boot-starter</artifactId>  
  35.             <version>1.3.2</version>  
  36.         </dependency>  
  37.         <dependency>  
  38.             <groupId>org.apache.tomcat.embed</groupId>  
  39.             <artifactId>tomcat-embed-jasper</artifactId>  
  40.             <scope>provided</scope>  
  41.         </dependency>  
  42.           
  43.         <dependency>  
  44.             <groupId>javax.servlet</groupId>  
  45.             <artifactId>jstl</artifactId>  
  46.         </dependency>  
  47.         <dependency>  
  48.             <groupId>org.springframework.boot</groupId>  
  49.             <artifactId>spring-boot-devtools</artifactId>  
  50.             <scope>runtime</scope>  
  51.         </dependency>  
  52.         <dependency>  
  53.             <groupId>mysql</groupId>  
  54.             <artifactId>mysql-connector-java</artifactId>  
  55.             <scope>runtime</scope>  
  56.         </dependency>  
  57.         <dependency>  
  58.             <groupId>org.springframework.boot</groupId>  
  59.             <artifactId>spring-boot-starter-tomcat</artifactId>  
  60.             <scope>provided</scope>  
  61.         </dependency>  
  62.         <dependency>  
  63.             <groupId>org.springframework.boot</groupId>  
  64.             <artifactId>spring-boot-starter-test</artifactId>  
  65.             <scope>test</scope>  
  66.         </dependency>  
  67.         <dependency>  
  68.             <groupId>com.github.pagehelper</groupId>  
  69.             <artifactId>pagehelper-spring-boot-starter</artifactId>  
  70.             <version>1.2.3</version>  
  71.         </dependency>  
  72.     </dependencies>  
  73.   
  74.     <build>  
  75.         <plugins>  
  76.             <plugin>  
  77.                 <groupId>org.springframework.boot</groupId>  
  78.                 <artifactId>spring-boot-maven-plugin</artifactId>  
  79.             </plugin>  
  80.         </plugins>  
  81.     </build>  
  82.   
  83.   
  84. </project>  
[html] view plain copy
  1. web.xml  
[html] view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">  
  3.   <display-name>springmvc-01</display-name>  
  4.   <welcome-file-list>  
  5.     <welcome-file>index.html</welcome-file>  
  6.     <welcome-file>index.htm</welcome-file>  
  7.     <welcome-file>index.jsp</welcome-file>  
  8.     <welcome-file>default.html</welcome-file>  
  9.     <welcome-file>default.htm</welcome-file>  
  10.     <welcome-file>default.jsp</welcome-file>  
  11.   </welcome-file-list>  
  12.     
  13.    <context-param>  
  14.     <param-name>contextConfigLocation</param-name>  
  15.     <param-value>classpath:spring-redis.xml,classpath:spring-mongo.xml</param-value>   
  16.   </context-param>  
  17.     
  18.   <listener>  
  19.     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  20.   </listener>  
  21.     
  22.   <!-- 前端控制器 -->  
  23.   <servlet>  
  24.     <servlet-name>springmvc</servlet-name>  
  25.     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
  26.     <!-- 默認找 /WEB-INF/[servlet的名稱]-servlet.xml -->  
  27.     <init-param>  
  28.         <param-name>contextConfigLocation</param-name>  
  29.         <param-value>classpath:springmvc.xml</param-value>  
  30.     </init-param>  
  31.   </servlet>  
  32.     
  33.   <servlet-mapping>  
  34.     <servlet-name>springmvc</servlet-name>  
  35.     <!--   
  36.         1. /*  攔截所有   jsp  js png .css  真的全攔截   建議不使用  
  37.         2. *.action *.do 攔截以do action 結尾的請求     肯定能使用   ERP    
  38.         3. /  攔截所有 (不包括jsp) (包含.js .png.css)  強烈建議使用     前臺 面向消費者  www.jd.com/search   /對靜態資源放行  
  39.      -->  
  40.     <url-pattern>*.action</url-pattern>  
  41.   </servlet-mapping>  
  42.     
  43.     <!-- 過濾器 -->  
  44.   <filter>  
  45.     <filter-name>myfilter</filter-name>  
  46.     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
  47.     <init-param>  
  48.         <param-name>encoding</param-name>  
  49.         <param-value>UTF-8</param-value>  
  50.     </init-param>  
  51.     <init-param>  
  52.         <param-name>forceEncoding</param-name>  
  53.         <param-value>true</param-value>  
  54.     </init-param>       
  55.   </filter>  
  56.     
  57.   <filter-mapping>  
  58.     <filter-name>myfilter</filter-name>  
  59.     <url-pattern>/*</url-pattern>  
  60.   </filter-mapping>  
  61.     
  62. </web-app>  
[html] view plain copy
  1. mapper.xml  
[html] view plain copy
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >  
  3. <mapper namespace="com.xinxin.mapper.ITableMapper">  
  4.   
  5. </mapper>  
配置完就可以啓動成功了!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章