首页
技术小册
AIGC
面试刷题
技术文章
MAGENTO
云计算
视频课程
源码下载
PDF书籍
「涨薪秘籍」
登录
注册
第一章:分模块开发和设计
1.1 项目目录结构
1.2 相关模块及代码
第二章:聚合和继承
2.1 聚合
2.2 继承
2.3 聚合和继承的异同点
第三章:属性
3.1 自定义属性
3.2 内置属性
3.3 Settings 属性
3.4 Java 系统属性
3.5 环境变量属性
第四章:版本管理
4.1 工程版本
4.2 工程版本号的约定
第五章:资源配置
第六章:多环境开发配置
6.1 多环境开发
6.2 多环境配置
6.3 加载指定环境
第七章:跳过测试
7.1 跳过测试环境的应用场景
7.2 跳过测试
第八章:私服
8.1 Nexus
8.2 Nexus的安装、启动和配置
8.3 私服资源获取
8.4 仓库的分类
8.5 登录Nexus
8.5 创建仓库
8.6 将仓库添加到maven-public
8.7 手动上传组件
8.8 IDEA环境中资源管理
当前位置:
首页>>
技术小册>>
Java必知必会-Maven高级
小册名称:Java必知必会-Maven高级
1.2.1 maven-ssm - 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.0</modelVersion> <groupId>com.xudaxian</groupId> <artifactId>maven-ssm</artifactId> <version>1.0</version> <!-- 定义该工程用于进行构建管理 --> <packaging>pom</packaging> <!-- 管理的工程列表 --> <modules> <!-- 具体的工程名称 --> <module>maven-ssm-pojo</module> <module>maven-ssm-dao</module> <module>maven-ssm-service</module> <module>maven-ssm-web</module> </modules> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> <!-- 声明此处进行依赖管理 --> <dependencyManagement> <!-- 具体的依赖 --> <dependencies> <!-- 自定义工程依赖 --> <dependency> <groupId>com.xudaxian</groupId> <artifactId>maven-ssm-service</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.xudaxian</groupId> <artifactId>maven-ssm-pojo</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.xudaxian</groupId> <artifactId>maven-ssm-dao</artifactId> <version>1.0</version> </dependency> <!-- spring的环境 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.1.9.RELEASE</version> </dependency> <!-- Spring整合Junit --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>5.1.9.RELEASE</version> </dependency> <!-- mybatis的环境 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.3</version> </dependency> <!--mysql环境--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.25</version> </dependency> <!--spring整合jdbc--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>5.1.9.RELEASE</version> </dependency> <!--spring整合mybatis--> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>2.0.3</version> </dependency> <!--druid连接池--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.16</version> </dependency> <!--分页插件坐标--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.1.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.1.9.RELEASE</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.9.0</version> </dependency> </dependencies> </dependencyManagement> <!-- 可以在子工程中定义依赖关系,无需声明依赖版本,版本将参考父工程中依赖的版本。 当然,我直接定义在父工程了。 --> <dependencies> <!-- spring的环境 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> <!-- Spring整合Junit --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> </dependency> <!-- mybatis的环境 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </dependency> <!--mysql环境--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!--spring整合jdbc--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> <!--spring整合mybatis--> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> </dependency> <!--druid连接池--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> <!--分页插件坐标--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> </dependencies> <build> <pluginManagement> <plugins> <!--具体的插件配置--> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> <port>80</port> <path>/</path> </configuration> </plugin> </plugins> </pluginManagement> </build> </project> ``` 1.2.2 maven-ssm-pojo - 目录结构: ![](/uploads/images/20230727/a1c2c26b68cf6adb645f0484aa7d2d2a.png) - 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"> <parent> <artifactId>maven-ssm</artifactId> <groupId>com.xudaxian</groupId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>maven-ssm-pojo</artifactId> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> </project> ``` - com.xudaxian.domain.User.java ``` package com.xudaxian.domain; import java.io.Serializable; import java.util.Date; /** * User * * @author maxiaoke.com * @version 1.0 * @since 2021 -06-14 07:25 */ public class User implements Serializable { private String uuid; private String username; private String password; private String realName; private Integer gender; private Date birthday; public String getUuid() { return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getRealName() { return realName; } public void setRealName(String realName) { this.realName = realName; } public Integer getGender() { return gender; } public void setGender(Integer gender) { this.gender = gender; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } @Override public String toString() { return "User{" + "uuid='" + uuid + '\'' + ", username='" + username + '\'' + ", password='" + password + '\'' + ", realName='" + realName + '\'' + ", gender=" + gender + ", birthday=" + birthday + '}'; } } ``` 1.2.3 maven-ssm-dao - 目录结构: ![](/uploads/images/20230727/9af6809cbf4d660e2aa76dd2c581bc56.png) - 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"> <parent> <artifactId>maven-ssm</artifactId> <groupId>com.xudaxian</groupId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>maven-ssm-dao</artifactId> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> <!-- 导入资源文件pojo --> <dependency> <groupId>com.xudaxian</groupId> <artifactId>maven-ssm-pojo</artifactId> </dependency> <!-- 单元测试 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> </dependencies> </project> ``` - com.xudaxian.mapper.UserMapper.java ``` package com.xudaxian.mapper; import com.xudaxian.domain.User; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * @author maxiaoke.com * @version 1.0 * */ @Mapper public interface UserMapper { /** * 添加用户信息 * * @param user 用户信息对象 * @return 如果新增成功,则返回true;否则,返回false */ boolean save( User user); /** * 修改用户信息 * * @param user 用户信息对象 * @return 如果修改成功,则返回true;否则,返回false */ boolean update( User user); /** * 删除用户信息 * * @param uuid 主键 * @return 如果删除成功,则返回true;否则,返回false */ boolean delete(String uuid); /** * 根据主键查询用户信息 * * @param uuid 主键 * @return 用户信息 */ User get(String uuid); /** * 查询全部用户信息 * * @return 全部用户信息 */ List<User> getAll(); /** * 根据用户名和密码查询用户信息 * * @param username 用户名 * @param password 密码 * @return 用户信息 */ User getByUsernameAndPassword(@Param("username") String username, @Param("password") String password); } ``` - com/xudaxian/mapper/UserMapper.xml ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.xudaxian.mapper.UserMapper"> <insert id="save"> INSERT INTO `user` (uuid, username, password, realName, gender, birthday) VALUES (#{uuid}, #{username}, #{password}, #{realName}, #{gender}, #{birthday}) </insert> <update id="update"> UPDATE `user` SET username=#{username}, password=#{password}, realName=#{realName}, gender=#{gender}, birthday=#{birthday} WHERE uuid = #{uuid} </update> <delete id="delete"> DELETE FROM `user` WHERE uuid = #{uuid} </delete> <select id="get" resultType="com.xudaxian.domain.User"> SELECT * FROM `user` WHERE uuid = #{uuid} </select> <select id="getAll" resultType="com.xudaxian.domain.User"> SELECT * FROM `user` </select> <select id="getByUsernameAndPassword" resultType="com.xudaxian.domain.User"> SELECT * FROM `user` WHERE username = #{username} AND password = #{password} </select> </mapper> ``` - jdbc.properties ``` jdbc.driver=com.mysql.cj.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/maven?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true jdbc.username=root jdbc.password=123456 ``` - applicationContext-dao.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" 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 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!--开启bean注解扫描--> <context:component-scan base-package="com.xudaxian"> <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController"/> </context:component-scan> <!--加载properties文件--> <context:property-placeholder location="classpath*:jdbc.properties"/> <!--数据源--> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${jdbc.driver}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <!--整合mybatis到spring中--> <bean class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="typeAliasesPackage" value="com.xudaxian.mapper"/> <!--分页插件--> <property name="plugins"> <array> <bean class="com.github.pagehelper.PageInterceptor"> <property name="properties"> <props> <prop key="helperDialect">mysql</prop> <prop key="reasonable">true</prop> </props> </property> </bean> </array> </property> </bean> <!--映射扫描--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.xudaxian.mapper"/> </bean> </beans> ``` 1.2.4 maven-ssm-service - 目录结构: ![](/uploads/images/20230727/600beca05c32ae2fb3e500be7c60dd84.png) - 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"> <parent> <artifactId>maven-ssm</artifactId> <groupId>com.xudaxian</groupId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>maven-ssm-service</artifactId> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>com.xudaxian</groupId> <artifactId>maven-ssm-dao</artifactId> </dependency> <!-- 单元测试 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> </dependencies> </project> ``` - com.xudaxian.service.UserService.java ``` package com.xudaxian.service; import com.github.pagehelper.PageInfo; import com.xudaxian.domain.User; /** * @author maxiaoke.com * @version 1.0 * */ public interface UserService { /** * 保存用户信息 * * @param user 用户信息 * @return */ boolean save(User user); /** * 更新用户信息 * * @param user 用户信息 * @return */ boolean update(User user); /** * 删除用户信息 * * @param uuid 主键 * @return */ boolean delete(String uuid); /** * 根据主键获取用户信息 * * @param uuid 主键 * @return */ User get(String uuid); /** * 分页显示用户信息 * * @param page 页码 * @param size 每页显示条数 * @return */ PageInfo<User> getAll(int page, int size); /** * 根据用户名和密码登录 * * @param userName * @param password * @return */ User login(String userName, String password); } ``` - com.xudaxian.service.impl.UserServiceImpl.java ``` package com.xudaxian.service.impl; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.xudaxian.domain.User; import com.xudaxian.mapper.UserMapper; import com.xudaxian.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * @author maxiaoke.com * @version 1.0 * */ @Transactional @Service public class UserServiceImpl implements UserService { @Autowired private UserMapper userMapper; @Override public boolean save(User user) { return userMapper.save(user); } @Override public boolean update(User user) { return userMapper.update(user); } @Override public boolean delete(String uuid) { return userMapper.delete(uuid); } @Override public User get(String uuid) { return userMapper.get(uuid); } @Override public PageInfo<User> getAll(int page, int size) { PageHelper.startPage(page, size); List<User> userList = userMapper.getAll(); return new PageInfo<>(userList); } @Override public User login(String userName, String password) { return userMapper.getByUsernameAndPassword(userName, password); } } ``` - applicationContext-service.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" 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 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!--开启bean注解扫描--> <context:component-scan base-package="com.xudaxian"> <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController"/> </context:component-scan> <!-- 导入applicationContext-dao.xml文件 --> <import resource="classpath*:applicationContext-dao.xml"/> <!--开启注解式事务--> <tx:annotation-driven transaction-manager="txManager"/> <!--事务管理器--> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> </beans> ``` 1.2.5 maven-ssm-web - 目录结构: ![](/uploads/images/20230727/0e04ea40592ff3a568a6f8fb23262889.png) - 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"> <!-- 定义该工程的父工程 --> <parent> <artifactId>maven-ssm</artifactId> <groupId>com.xudaxian</groupId> <version>1.0</version> <!-- 填写父工程的pom文件,如果是下面的这种格式,可以省略relativePath --> <relativePath>../pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>maven-ssm-web</artifactId> <packaging>war</packaging> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>com.xudaxian</groupId> <artifactId>maven-ssm-service</artifactId> </dependency> </dependencies> <build> <!--设置插件--> <plugins> <!--具体的插件配置--> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> </plugin> </plugins> </build> </project> ``` - com.xudaxian.utils.Code.java ``` package com.xudaxian.utils; import java.io.Serializable; /** * @author maxiaoke.com * @version 1.0 * */ public class Code implements Serializable { // 操作结果编码 public static final Integer SAVE_OK = 20011; public static final Integer UPDATE_OK = 20021; public static final Integer DELETE_OK = 20031; public static final Integer GET_OK = 20041; public static final Integer SAVE_ERROR = 20010; public static final Integer UPDATE_ERROR = 20020; public static final Integer DELETE_ERROR = 20030; public static final Integer GET_ERROR = 20040; // 系统错误编码 // 操作权限编码 // 校验结果编码 } ``` - com.xudaxian.utils.Result.java ``` package com.xudaxian.utils; import java.io.Serializable; /** * @author maxiaoke.com * @version 1.0 * */ public class Result implements Serializable { // 操作结果编码 private Integer code; // 操作数据结果 private Object data; // 消息 private String message; public Result(Integer code) { this.code = code; } public Result(Integer code, Object data) { this.code = code; this.data = data; } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public Object getData() { return data; } public void setData(Object data) { this.data = data; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } @Override public String toString() { return "Result{" + "code=" + code + ", data=" + data + ", message='" + message + '\'' + '}'; } } ``` - com.xudaxian.web.UserController.java ``` package com.xudaxian.web; import com.github.pagehelper.PageInfo; import com.xudaxian.domain.User; import com.xudaxian.service.UserService; import com.xudaxian.utils.Code; import com.xudaxian.utils.Result; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * @author maxiaoke.com * @version 1.0 * */ @RestController @RequestMapping("/user") public class UserController { @Autowired private UserService userService; @PostMapping public Result save(User user) { boolean flag = userService.save(user); return new Result(flag ? Code.SAVE_OK : Code.SAVE_ERROR); } @PutMapping public Result update(User user) { boolean flag = userService.update(user); return new Result(flag ? Code.UPDATE_OK : Code.UPDATE_ERROR); } @DeleteMapping("/{uuid}") public Result delete(@PathVariable String uuid) { boolean flag = userService.delete(uuid); return new Result(flag ? Code.DELETE_OK : Code.DELETE_ERROR); } @GetMapping("/{uuid}") public Result get(@PathVariable String uuid) { User user = userService.get(uuid); return new Result(null != user ? Code.GET_OK : Code.GET_ERROR, user); } @GetMapping("/{page}/{size}") public Result getAll(@PathVariable Integer page, @PathVariable Integer size) { PageInfo<User> all = userService.getAll(page, size); return new Result(null != all ? Code.GET_OK : Code.GET_ERROR, all); } @PostMapping("/login") public Result login(String userName, String password) { User user = userService.login(userName, password); return new Result(null != user ? Code.GET_OK : Code.GET_ERROR, user); } } ``` - applicationContext.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" 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 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <context:component-scan base-package="com.xudaxian"> <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController"/> </context:component-scan> <import resource="classpath*:applicationContext-service.xml"/> </beans> ``` - spring-mvc.xml ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" 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 http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <mvc:annotation-driven/> <context:component-scan base-package="com.xudaxian.web"> <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController"/> </context:component-scan> </beans> ``` - webapp/WEB-INF/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_3_1.xsd" version="3.1"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext.xml</param-value> </context-param> <!--启动服务器时,通过监听器加载spring运行环境--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>CharacterEncodingFilter</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>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>DispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:spring-mvc.xml</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>DispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> ```
上一篇:
1.1 项目目录结构
下一篇:
第二章:聚合和继承
该分类下的相关小册推荐:
Java语言基础7-Java中的异常
Java语言基础14-枚举和注解
Java性能调优实战
java源码学习笔记
Mybatis合辑3-Mybatis动态SQL
Mybatis合辑5-注解、扩展、SQL构建
手把手带你学习SpringBoot-零基础到实战
Java并发编程
Java语言基础3-流程控制
Java语言基础2-运算符
Java并发编程实战
Java语言基础4-数组详解