maven笔记1

maven 项目
第一步,在这里插入图片描述
将其替换成jdk1.8
然后
在这里插入图片描述
在这里插入图片描述
点击project Facts 手动将jdk改成1.8
在这里插入图片描述
然后关闭eclipse,打开eclipse的工作空间xxspaces,找到刚才哪个项目,
在这里插入图片描述
双击进入,
在这里插入图片描述
进入.settings,
在这里插入图片描述
用记事本打开它,2.3改为3.0
在这里插入图片描述
然后打开eclipse
在这里插入图片描述
此时它已经变为3.0。注意,不能在这个地方手动改,因为它会报错。(未演示此情况)
然后在pom.xml里进行配置要使用的jar包
在这里插入图片描述
然后就和ssm一样开始写了
配置web.xml
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>SSM_MavenDemo01</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  
  
  <servlet>
  <servlet-name>springmvc</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  </servlet>
  
  <servlet-mapping>
  <servlet-name>springmvc</servlet-name>
  <url-pattern>/</url-pattern>
  
  </servlet-mapping>
  
  <filter>
  <filter-name>encod</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>encod</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
  
</web-app>

接下来时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:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" 
	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"></context:component-scan>
		
		<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"> 
		<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
		<property name="url" value="jdbc:mysql://localhost:3306/chl?serverTimezone=Asia/Shanghai"></property>
		<property name="username" value="root"></property>
		<property name="password" value="123456"></property>
		
		</bean>
		
		
		<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource"></property>
		<property name="configLocation" value="classpath:com/mybatis/mybatis-config.xml"></property>
		</bean>
		
		
		<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.dao"></property>
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
		</bean>
		                                     
		<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
	       <property name="defaultEncoding" value="utf-8"></property>
	       <property name="maxUploadSize" value="102400000"></property>
        </bean>
		
		</beans>

接下来写包
在这里插入图片描述
配置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>
	
	<mappers>
	<!-- 映射文件的位置 -->
	<mapper resource="com/mybatis/StudentMapper.xml"/>
	</mappers>
</configuration>

接下来时mapper.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">
<!-- namespace属性指向dao层接口的位置 -->
<mapper namespace="com.dao.TestDao">
</mapper>

ok,简单的maven就创好了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值