2.基础环境搭建

来源:互联网 发布:男士去黑眼圈知乎 编辑:程序博客网 时间:2024/05/20 23:32

关于maven的一篇很好的博文:http://www.cnblogs.com/hongwz/p/5456578.html

1.新建一个maven project

这里写图片描述

因为这是一个JavaWeb程序,所以Packaging是war。

2.配置maven的mirror和profile

 <mirror>        <id>alimaven</id>        <name>aliyun maven</name>        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>        <mirrorOf>central</mirrorOf>    </mirror>
<profile>        <id>jdk17</id>        <activation>            <activeByDefault>true</activeByDefault>            <jdk>1.7</jdk>        </activation>        <proporties>            <maven.compiler.source>1.7</maven.compiler.source>            <maven.compiler.target>1.7</maven.compiler.target>            <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>        </proporties>    </profile>

3.引入项目依赖jar包

maven仓库:https://mvnrepository.com/

注:()里是maven仓库搜索jar的名称

- SpringMVC (spring webmvc)
- Spring JDBC(Spring jdbc)
- Spring面向对象编程(Spring aspects)
- Mybatis(mybatis)
- mybatis整合Spring的适配包(mybatis Spring)
- 数据库连接池(c3p0)
- MySQL驱动(mysql)
- jstl(jstl)
- servletAPI(servletAPI)
- 单元测试(Junit)

4.引入bootstrap框架

bootstrap官网:http://v3.bootcss.com/getting-started/

  1. 在webapp下建一个文件夹(我建的是static,名字随便起)用来存放bootstrap文件。
  2. 在前端jsp页面引入bootstrap的样式和脚本
<!-- Bootstrap样式 -->    <link href="static/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"><!-- bootstrap的脚本 -->    <script src="static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

3.引入jQuery文件:

<!-- jQuery -->    <script type="text/javascript" herf="static/js/jquery-3.1.1.min.js"></script>

5.pom.xml代码:

<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.lee</groupId>  <artifactId>crud</artifactId>  <version>0.0.1-SNAPSHOT</version>  <packaging>war</packaging>  <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->  <dependencies>    <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-webmvc</artifactId>        <version>4.3.7.RELEASE</version>    </dependency>    <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc --><dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-jdbc</artifactId>    <version>4.3.7.RELEASE</version></dependency>    <!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects --><dependency>    <groupId>org.springframework</groupId>    <artifactId>spring-aspects</artifactId>    <version>4.3.7.RELEASE</version></dependency>    <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis --><dependency>    <groupId>org.mybatis</groupId>    <artifactId>mybatis</artifactId>    <version>3.4.1</version></dependency>    <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring --><dependency>    <groupId>org.mybatis</groupId>    <artifactId>mybatis-spring</artifactId>    <version>1.3.0</version></dependency>    <!-- https://mvnrepository.com/artifact/c3p0/c3p0 --><dependency>    <groupId>c3p0</groupId>    <artifactId>c3p0</artifactId>    <version>0.9.1.2</version></dependency>    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --><dependency>    <groupId>mysql</groupId>    <artifactId>mysql-connector-java</artifactId>    <version>6.0.6</version></dependency>    <!-- https://mvnrepository.com/artifact/jstl/jstl --><dependency>    <groupId>jstl</groupId>    <artifactId>jstl</artifactId>    <version>1.2</version></dependency>    <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --><dependency>    <groupId>javax.servlet</groupId>    <artifactId>javax.servlet-api</artifactId>    <version>3.1.0</version>    <scope>provided</scope></dependency>    <!-- https://mvnrepository.com/artifact/junit/junit --><dependency>    <groupId>junit</groupId>    <artifactId>junit</artifactId>    <version>4.12</version>    <scope>test</scope></dependency>  </dependencies></project>
原创粉丝点击