IDEA搭建SSM框架教程 從零開始 SSM+Maven框架搭建教程


項目需求:

使用 : Spring+Mybatis+Spring-mvc 搭建項目 實現用戶的登錄

開發環境:
intellij idea:2019 + maven:3.5.4 +  jdk:1.8

接下來直接開始流水線式教程

搭建不成功別着急 也別在一個問題上卡死 我為了學這個 應該練習了不少於20次,第一次的話 我覺得沒有一個人能一次成功!

 

Maven下載特別慢 直接翻到文章最下面 有解決方法

 

1、新建項目

2.配置搭建的基礎配置

3.一切選擇完了以后選擇 Next  進入項目名稱設置

4,配置項目名稱 等等  改成自己的項目名稱 也可以默認

 

項目新建完成了 開始配置項目的整體結構

這個是我項目的結構 搭建的時候可以參考下 如果哪里出問題了 記得看看結構是不是有問題  下面介紹下每個文件夾都是干嘛的

java - 存放項目源代碼的 -  包括 : controller 控制層,mapper 接口層 我的 sql映射文件也放在這個里面了(這里不明白先不管往下走) ,pojo實體類,service業務邏輯層  這邊非常相似 最初版本的三層模式

resources - 存放項目配置文件的  ,后面文章的配置文件部分都是放在這里的

webapp - 建完項目自動會生成 (一般情況下 有些人就沒有 我曾經也沒有)   這個沒有的話百度 看看 實在不行的話應該是我的鍋 我的新建項目過程比較簡陋 看看別的博主的 應該能解決  這個里面 有個static的文件夾里面放的就是css , js , images 這些東西 jsp目錄就是jsp的內容 路徑這邊盡量就按照我的來 因為方便后面配置文件

 
         
         
        

前面基本上都是IDEA怎么新建Maven項目  介紹的不夠詳細 也可以去參考別的博客 下面直接開始干貨 (特別提醒:復制的時候記得把配置文件映射的路徑等等改成自己的項目路徑 不要無腦的亂來

 

1.配置pom.xml 配置pom文件 copy的時候看着點 不要copy 

 

下面這句話自己看着點 這個是防止xml文件不編譯的

 

    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.properties</include>
          <include>**/*.html</include>
        </includes>
      </resource>
    </resources>

 

 

<?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>hoverObServerApp</groupId>
  <artifactId>com.24timegcy</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>com.24timegcy Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <!-- 設置項目編碼編碼 -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <!-- spring版本號 -->
    <spring.version>4.3.5.RELEASE</spring.version>
    <!-- mybatis版本號 -->
    <mybatis.version>3.4.1</mybatis.version>
  </properties>

  <dependencies>
    <!-- java ee -->
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>7.0</version>
    </dependency>

    <!-- 單元測試 -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>

    <!-- 實現slf4j接口並整合 -->
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.2.2</version>
    </dependency>

    <!-- JSON -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.8.7</version>
    </dependency>


    <!-- 數據庫 -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.41</version>
      <scope>runtime</scope>
    </dependency>

    <!-- 數據庫連接池 -->
    <dependency>
      <groupId>com.mchange</groupId>
      <artifactId>c3p0</artifactId>
      <version>0.9.5.2</version>
    </dependency>

    <!-- MyBatis -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>${mybatis.version}</version>
    </dependency>

    <!-- mybatis/spring整合包 -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.3.1</version>
    </dependency>

    <!-- Spring -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${spring.version}</version>
    </dependency>
  </dependencies>

  <build>
    <finalName>com.24timegcy</finalName>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-war-plugin</artifactId>
          <version>3.2.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.properties</include>
          <include>**/*.html</include>
        </includes>
      </resource>
    </resources>
  </build>
</project>

 

2.新建 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"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
    <!-- 加載配置文件 *.properties -->
    <context:property-placeholder
            location="classpath:jdbc.properties"/>

    <!--配置數據庫 dataSource -->
    <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}"/>
        <!-- 最大並發連接數 -->
        <property name="maxPoolSize" value="30"/>
        <!-- 最小空閑連接數 -->
        <property name="minPoolSize" value="5"/>
    </bean>

    <!-- 配置sqlsessioFactory -->
    <bean id="sqlSessionFactoryBean"
          class="org.mybatis.spring.SqlSessionFactoryBean">
        <!-- 配置數據源 引用(ref)dataSource(bean) -->
        <property name="dataSource" ref="dataSource"/>
        <!-- 加載mybatis 配置文件 -->
        <property name="configLocation"
                  value="classpath:mybatis.xml"/>
        <property name="mapperLocations" value="classpath:com/hover/mapper/*Mapper.xml"/>
    </bean>

    <!-- 配置掃描包 加載mapper代理對象 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <!-- 掃描mapper路徑 -->
        <property name="basePackage" value="com.hover.mapper"/>
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean"/>
    </bean>

    <!-- 掃描Service包 -->
    <context:component-scan
            base-package="com.hover.service"/>
</beans>

3.新建jdbc.properties配置文件 這個是數據庫的配置信息 記得里面的東西改成跟你相關的

jdbc.driver=com.mysql.jdbc.Driver
#數據庫地址
jdbc.url=jdbc:mysql://localhost:3306/24-hourobserver?useUnicode=true&characterEncoding=utf8
#用戶名
jdbc.username=root
#密碼
jdbc.password=1234

4.新建mybatis.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>
    <!-- 開啟二級緩存 -->
    <settings>
        <!--<setting name="cacheEnabled" value="true"/>-->
        <!-- 是否開啟二級緩存 默認為true -->
        <setting name="cacheEnabled" value="true"/>
        <!-- 是否懶加載 -->
        <setting name="lazyLoadingEnabled" value="true" />
    </settings>

    <typeAliases>
        <!--批量配置別名-->
        <package name="com.hover.pojo"/>
    </typeAliases>
</configuration>

新建 spring-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:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd">

    <!--1.注解掃描位置-->
    <context:component-scan base-package="com.hover.controller"/>

    <mvc:resources location="/static/" mapping="/static/**"></mvc:resources>
    <mvc:annotation-driven >
        <!-- 消息轉換器 -->
        <mvc:message-converters register-defaults="true">
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <property name="supportedMediaTypes" value="text/plain;charset=UTF-8"/>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>

    <!--2.配置映射處理和適配器-->
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
    <!--3.視圖的解析器-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

</beans>

 

配置Web.xml配置文件

<!DOCTYPE web-app PUBLIC
        "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd" >

<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">
    <display-name>Archetype Created Web Application</display-name>

    <!-- 配置SprongIoC容器加載的配置文件 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>

    <context-param>
        <param-name>log4jRefreshInterval</param-name>
        <param-value>6000</param-value>
    </context-param>

    <!-- 用於初始化SpringIoC容器 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>


    <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 -->
        <load-on-startup>1</load-on-startup>
        <multipart-config>
            <location>e:/upimgs</location>
            <max-file-size>5242880</max-file-size>
            <max-request-size>10485760</max-request-size>
            <file-size-threshold>0</file-size-threshold>
        </multipart-config>
    </servlet>


    <servlet-mapping>
        <!-- 約定優於配置,Spring MVC框架默認加載/WEB-INF/<servlet-name/>開頭-servlet.xml作為配置文件載入web工程中-->
        <servlet-name>DispatcherServlet</servlet-name>
        <!-- 攔截配置 -->
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>/WEB-INF/jsp/login.jsp</welcome-file>
    </welcome-file-list>

    <!--亂碼過濾器-->
    <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>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

 

=====================都完了以后配置文件基本上就完事了========================

 

開始具體的功能部分

1.新建實體類 建在 java-包名-pojo里面 我里面的東西這個請不要照搬 跟着你的數據庫來

package com.hover.pojo;

import java.util.Date;
/**
 * 用戶表
 * @author Yang
 *
 */
public class Users {
    private Integer u_id;                //用戶編號
    private Integer r_id;                //角色編號
    private String u_mobilephone;        //手機號
    private String u_password;            //密碼
    private Date u_createDate;            //注冊時間
    private String u_weiboaccount;        //微信賬號
    private String u_qqaccount;            //QQ賬號
    private String u_weChataccount;        //微博賬號
    private Integer u_delete;            //物理是否被刪除
    private Userinformation userInfo;   //用戶詳細信息
    //無參構造
    public Users() {
        super();
        // TODO Auto-generated constructor stub
    }
    //全參構造
    public Users(Integer u_id, Integer r_id, String u_mobilephone,
            String u_password, Date u_createDate, String u_weiboaccount,
            String u_qqaccount, String u_weChataccount, Integer u_delete) {
        super();
        this.u_id = u_id;
        this.r_id = r_id;
        this.u_mobilephone = u_mobilephone;
        this.u_password = u_password;
        this.u_createDate = u_createDate;
        this.u_weiboaccount = u_weiboaccount;
        this.u_qqaccount = u_qqaccount;
        this.u_weChataccount = u_weChataccount;
        this.u_delete = u_delete;
    }
    //get set
    public Integer getU_id() {
        return u_id;
    }
    public void setU_id(Integer u_id) {
        this.u_id = u_id;
    }
    public Integer getR_id() {
        return r_id;
    }
    public void setR_id(Integer r_id) {
        this.r_id = r_id;
    }
    public String getU_mobilephone() {
        return u_mobilephone;
    }
    public void setU_mobilephone(String u_mobilephone) {
        this.u_mobilephone = u_mobilephone;
    }
    public String getU_password() {
        return u_password;
    }
    public void setU_password(String u_password) {
        this.u_password = u_password;
    }
    public Date getU_createDate() {
        return u_createDate;
    }
    public void setU_createDate(Date u_createDate) {
        this.u_createDate = u_createDate;
    }
    public String getU_weiboaccount() {
        return u_weiboaccount;
    }
    public void setU_weiboaccount(String u_weiboaccount) {
        this.u_weiboaccount = u_weiboaccount;
    }
    public String getU_qqaccount() {
        return u_qqaccount;
    }
    public void setU_qqaccount(String u_qqaccount) {
        this.u_qqaccount = u_qqaccount;
    }
    public String getU_weChataccount() {
        return u_weChataccount;
    }
    public void setU_weChataccount(String u_weChataccount) {
        this.u_weChataccount = u_weChataccount;
    }
    public Integer getU_delete() {
        return u_delete;
    }
    public void setU_delete(Integer u_delete) {
        this.u_delete = u_delete;
    }
    public Userinformation getUserInfo() {
        return userInfo;
    }
    public void setUserInfo(Userinformation userInfo) {
        this.userInfo = userInfo;
    }
    public Users(Integer u_id, Integer r_id, String u_mobilephone,
            String u_password, Date u_createDate, String u_weiboaccount,
            String u_qqaccount, String u_weChataccount, Integer u_delete,
            Userinformation userInfo) {
        super();
        this.u_id = u_id;
        this.r_id = r_id;
        this.u_mobilephone = u_mobilephone;
        this.u_password = u_password;
        this.u_createDate = u_createDate;
        this.u_weiboaccount = u_weiboaccount;
        this.u_qqaccount = u_qqaccount;
        this.u_weChataccount = u_weChataccount;
        this.u_delete = u_delete;
        this.userInfo = userInfo;
    }
    


}

2.新建 mapper的接口  可以看到 前面說的 我的映射文件 和 dao放一個包里面了 名字也一樣 方便管理

 

2.1 先看 UserMapper.java  這個 Mapper 也就是曾經的DAO接口

package com.hover.mapper;

import org.apache.ibatis.annotations.Param;

public interface UserMapper {

    /**
     * 用戶登錄的方法
     * @return
     */
    public Integer userLogin(@Param("userCode")String userCode,@Param("password")String password);
}

2.2下面是 UserMapper.xml 這個是Mapper的映射文件 (這邊強調一下 所有的命名都是 XXXMapper.xml)因為配置文件掃描的時候 我的規則是*Mapper.xml 你們也可改動 新手的話不要改了 (eg:我也是看着別的博主的博客學習 才會的 也是新手)

代碼里面的  <mapper namespace="com.hover.mapper.UserMapper"> 這句話當中的 namespace記得改成你的 這個相當於命名空間是唯一的  規范:包名+*Mapper的名字

<?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.hover.mapper.UserMapper">
    <select id="userLogin" resultType="java.lang.Integer">
        SELECT COUNT(1) FROM users WHERE u_mobilePhone=#{userCode} AND u_password=#{password} AND r_id&lt;=3
    </select>
</mapper>

3.下面來看UserService.java

package com.hover.service;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

@Service
public interface UserService {

    /**
     * 用戶登錄的方法
     * @return
     */
    public Integer userLogin(@Param("userCode")String userCode, @Param("password")String password);
}

4.接下來是 UserServiceImpl.java 也就是 Service層的實現 這邊 有用到注解

package com.hover.service.impl;

import com.hover.mapper.UserMapper;
import com.hover.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public Integer userLogin(String userCode,String password) {
        return userMapper.userLogin(userCode,password);
    }
}

5.下面就是最后一步了 UserController.java 控制層 如果是用Servlet的話 他應該跟Servlet作用差不多吧 我的理解 大佬勿噴 最后那個return "login" 是返回login.jsp 配置文件配置了 視圖解析器 所以說不用返回login.jsp 直接 login就行了

package com.hover.controller;

import com.hover.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/userController")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("userLogin")
    public String userLogin(@RequestParam("userCode")String userCode, @RequestParam("password")String password, HttpServletRequest request){
        Integer result=userService.userLogin(userCode,password);
        System.out.println("用戶的用戶名:"+userCode);
        System.out.println("用戶的密碼:"+password);
        if (result>0){
            System.out.println("登錄成功!");
            return "index";
        }else{
            System.out.println("登錄失敗!");
            request.setAttribute("error","賬號或者密碼輸入錯誤");
        }
        return "login";
    }

}

 

下面來看看 login.jsp的代碼

<%--
  Created by IntelliJ IDEA.
  User: Yang
  Date: 2019/8/25
  Time: 21:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登錄頁面</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/universalStyle.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/static/css/login.css"/>
</head>
<body>
<div id="login_form">
    <form action="${pageContext.request.contextPath }/userController/userLogin" method="post">
        <div id="login_left">
            <img src="${pageContext.request.contextPath }/static/img/login/loginImage.png"/>
        </div>
        <div id="login_right">
            <p>24小時觀察員</p>
            <div id="login_userName">
                <p>賬號*</p>
                <p><input type="text" name="userCode" required placeholder="請輸入賬號"/></p>
            </div>
            <div id="login_password">
                <p>密碼*</p>
                <p><input type="password" name="password" required placeholder="請輸入密碼"/></p>
            </div>
            <p><input type="submit" name="login"value="登陸"/></p>
            <p><img src="${pageContext.request.contextPath }/static/img/login/loginFailedImage.png"/>密碼輸入錯誤</p>
            <p><input type="checkbox" name="rememberPwd"/>記住密碼</p>
        </div>
    </form>
</div>
</body>
</html>

 

OK了基本上 就通了 其中好多地方都沒說明白 有什么問題在QQ聯系:1336486608 這個項目有點其他問題 暫時不能大家共享 有什么問題直接聯系我

 

前面基本上完成了項目搭建  這邊 有個Maven的配置 可以看看 使用阿里的倉庫下載jar包快  需要改一下 conf-settings.xml 配置文件 切換成 阿里的倉庫 你要是翻牆 什么的 那默認用國外的也行 具體Maven下載是個什么 自行百度

我那個下載地址在 E:maven 根據自己的 改就行

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  --> <localRepository>E:\maven</localRepository>

  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <!--<mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>-->
      <mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
  </mirror>
  <mirror>
    <id>nexus-163</id>
    <mirrorOf>*</mirrorOf>
    <name>Nexus 163</name>
    <url>http://mirrors.163.com/maven/repository/maven-public/</url>
  </mirror>
   <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
    

  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM