Eclipse Maven构建Spring MVC项目
工作中项目开发使用Maven管理项目的构建、打包、编译,框架採用的是Spring MVC框架,而且实现了多模块、多项目的管理。自己也简单的參与了架构的设计。对于刚開始学习的人来说,使用Maven构建项目并非一件easy的事情,本文的目的就是引导新手使用maven构建springmvc项目。
准本工作
1、Eclipse
尽量选用较高版本号的Eclispse,由于eclipse对于maven的支持比較晚。
2、Maven
安装maven,至于其安装方式这里也就不再多提了,请自行google。
3、Eclipse选择本地Maven,例如以下图所:
选择本地库的原因是你能够自行指定仓库的位置,也能够指定远程仓库,方便管理。
构建project
1、新建Maven项目
maven具有强大构建功能,使用maven能够构建多种不同类型的工程。这里我们构建maven-archhetype-webapp类型的项目。Eclipse->New中选择maven project,详细例如以下图:
之后选择构建类型:
接下来填写完Group id 和Artifact id
之后就可以新建一个空的Maven项目了。
一个空的演示样例项目文件夹结构例如以下:
似乎和完整的Maven项目还略有差距,不急,一步一步完好。
2、完好项目
上述项目结构离完整的maven项目结构另一定的距离,我们须要加入三个源目录src/main/java(核心源代码),src/test/java(測试代码:单元測试),src/test/resources(測试代码的配置文件)。当中已经有的src/main/resources为项目的配置文件放置路径。
只是在通过Eclipse新建三个源文件时,会出现一个奇怪的问题,例如以下所看到的:
一个解决的方法是我们直接定位到项目文件里(磁盘中),手动的新建该三个文件,之后刷新项目就可以。
当中src/test/resources貌似能够直接在Eclipse中直接新建。
3、加入web特性
对于版本号较高的Eclipse来说,到如今项目基本就是一个maven项目了,可是对于较老版本号来说还要进行一些操作。并且基于兴许项目打包、公布的考虑这里也须要做相关操作。
右键项目->Properties->Project Facets->动态web特性
因为项目打包、公布的时候不须要測试代码、測试的配置文件,以及执行时产生的额外文件(target),这里我们要进行下web文件夹的配置也就是Deployment Assembly,详细例如以下图:
删除蓝色框区域(老版本号可能需删除webContent文件夹,加入webapp文件夹)。
至此,一个完整的maven项目就构建好了,项目的结构例如以下:
Spring MVC配置
眼下为止仅仅是构建了maven项目,接下来一步一步来配置Spring MVC特性。
1、Spring MVC配置
配置web.xml,採用Spring MVC框架,主要配置的是ContextLoaderListener和DispacherServlet。web.xml配置例如以下:
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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">
- <display-name>LCore</display-name>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- <!-- 载入全部的配置文件
- 这里我将配置文件置于源代码包中
- -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath*:spring-*.xml</param-value>
- </context-param>
- <!-- 配置Spring-->
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <!-- 配置SpringMVC -->
- <servlet>
- <servlet-name>springMVC</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>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>springMVC</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- <!-- 配置字符集 -->
- <filter>
- <filter-name>encodingFilter</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>encodingFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <!-- 配置Session -->
- <filter>
- <filter-name>openSession</filter-name>
- <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>openSession</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- </web-app>
配置ContextLoaderListener表示,该project要以spring的方式启动。启动时会默认在/WEB-INF文件夹下查找 spring-common.xml作为spring容器的配置文件,这里能够初始化一些bean,如DataSource。代码例如以下:
- <?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:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
- <context:property-placeholder location="classpath:jdbc.properties" />
- <context:component-scan base-package="com.ceis.core" />
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
- p:driverClassName="${jdbc.driver}"
- p:url="${jdbc.url}"
- p:username="${jdbc.username}"
- p:password="${jdbc.password}" />
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.current_session_context_class">thread</prop>
- <prop key="hibernate.hbm2ddl.auto">update</prop>
- </props>
- </property>
- <property name="packagesToScan">
- <list>
- <value>com.ceis.core.po</value>
- </list>
- </property>
- </bean>
- <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <property name="sessionFactory" ref="sessionFactory" />
- </bean>
- <tx:annotation-driven proxy-target-class="true" />
- </beans>
配置DispatcherServlet表示,该project将採用springmvc的方式。启动时也会默认在classPath文件夹下查找spring-mvc.xml作为配置文件,该文件里将配置两项重要的mvc特性:
HandlerMapping,负责为DispatcherServlet这个前端控制器的请求查找Controller;
这里我额外配置了velocity引擎处理请求和视图解析器(页面通过velocity模板引擎构建)。代码例如以下:
- <?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:mvc="http://www.springframework.org/schema/mvc"
- 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-3.2.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
- <!-- 注解扫描包 -->
- <context:component-scan base-package="com.ceis.core.controller" />
- <!-- 启动spring mvc的注解功能,完毕请求和注解POJO的映射 -->
- <bean
- class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
- <!-- 配置信息转换,将用@responsebody注解的返回值转换为json返回前台,编码为utf-8-->
- <property name="messageConverters">
- <list>
- </list>
- </property>
- </bean>
- <mvc:interceptors>
- <mvc:interceptor>
- <mvc:mapping path="/*" />
- <!-- 需排除拦截的地址 -->
- <mvc:exclude-mapping path="/login" />
- <bean class="com.ceis.core.Interceptor.SecurityInterceptor" />
- </mvc:interceptor>
- </mvc:interceptors>
- <mvc:annotation-driven />
- <!-- 静态资源(js/image)的訪问 -->
- <mvc:resources mapping="/resources/**" location="/resources/" />
- <!-- 定义视图解析器 -->
- <!-- 配置velocity引擎处理请求 -->
- <bean id="velocityConfigurer"
- class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
- <!-- <property name="configLocation"> <value>/WEB-INF/toolbox.xml</value>
- </property> -->
- <property name="resourceLoaderPath">
- <value>/WEB-INF/views/</value>
- </property>
- <property name="velocityProperties">
- <props>
- <prop key="input.encoding">UTF-8</prop>
- <prop key="output.encoding">UTF-8</prop>
- </props>
- </property>
- </bean>
- <!-- 配置velocity视图解析器 -->
- <bean id="viewResolver"
- class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
- <property name="suffix">
- <value>.vm</value>
- </property>
- <property name="contentType" value="text/html;charset=UTF-8"></property>
- </bean>
- </beans>
2、Maven配置jar包
传统引入jar的方式是将其放入web-inf->lib文件夹里面,无形中增大了项目,并且jar不能统一进行管理。使用Maven的优点之中的一个就是通过配置POM.XML文件自己主动下载jar包,并且通过中心库统一进行管理、版本号的控制等。
这里我们须要引入spring-mvc、servlet特性相关的包,以及tomcat插件(执行)
- <?xml version="1.0"?>
- <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <groupId>debug</groupId>
- <artifactId>debug</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>war</packaging>
- <dependencies>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>3.1.2.RELEASE</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- <version>3.1.2.RELEASE</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>3.1.2.RELEASE</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>1.6.6</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.21</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>jstl</groupId>
- <artifactId>jstl</artifactId>
- <version>1.2</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>taglibs</groupId>
- <artifactId>standard</artifactId>
- <version>1.1.2</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-c3p0</artifactId>
- <version>3.6.0.Final</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-ehcache</artifactId>
- <version>3.6.10.Final</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>3.1.2.RELEASE</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>3.1.2.RELEASE</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-mock</artifactId>
- <version>2.0.8</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.5</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- <version>2.1_3</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- <version>3.4.GA</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>3.5.6-Final</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <version>3.5.6-Final</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
- <version>1.9.8</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.9.8</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <version>1.2.2</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.7</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-tools</artifactId>
- <version>2.0</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- <repositories>
- <repository>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>central</id>
- <name>Central Repository</name>
- <url>http://repo.maven.apache.org/maven2</url>
- </repository>
- </repositories>
- <pluginRepositories>
- <pluginRepository>
- <releases>
- <updatePolicy>never</updatePolicy>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <id>central</id>
- <name>Central Repository</name>
- <url>http://repo.maven.apache.org/maven2</url>
- </pluginRepository>
- </pluginRepositories>
- <build>
- <sourceDirectory>C:\Users\LCore\git\debug\debug\src</sourceDirectory>
- <scriptSourceDirectory>C:\Users\LCore\git\debug\debug\src\main\scripts</scriptSourceDirectory>
- <testSourceDirectory>C:\Users\LCore\git\debug\debug\src\test\java</testSourceDirectory>
- <outputDirectory>C:\Users\LCore\git\debug\debug\target\classes</outputDirectory>
- <testOutputDirectory>C:\Users\LCore\git\debug\debug\target\test-classes</testOutputDirectory>
- <resources>
- <resource>
- <directory>C:\Users\LCore\git\debug\debug\src\main\resources</directory>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <directory>C:\Users\LCore\git\debug\debug\src\test\resources</directory>
- </testResource>
- </testResources>
- <directory>C:\Users\LCore\git\debug\debug\target</directory>
- <finalName>debug-0.0.1-SNAPSHOT</finalName>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.3</version>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2-beta-5</version>
- </plugin>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.8</version>
- </plugin>
- <plugin>
- <artifactId>maven-release-plugin</artifactId>
- <version>2.3.2</version>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>tomcat-maven-plugin</artifactId>
- <version>1.1</version>
- <configuration>
- <url>http://127.0.0.1:8080/manager</url>
- <port>8080</port>
- <server>TomcatServer</server>
- <path>/debug</path>
- <uriEncoding>UTF-8</uriEncoding>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.5.1</version>
- <executions>
- <execution>
- <id>default-testCompile</id>
- <phase>test-compile</phase>
- <goals>
- <goal>testCompile</goal>
- </goals>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- <encoding>UTF-8</encoding>
- </configuration>
- </execution>
- <execution>
- <id>default-compile</id>
- <phase>compile</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- <encoding>UTF-8</encoding>
- </configuration>
- </execution>
- </executions>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.5</version>
- <executions>
- <execution>
- <id>default-clean</id>
- <phase>clean</phase>
- <goals>
- <goal>clean</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <version>2.4</version>
- <executions>
- <execution>
- <id>default-install</id>
- <phase>install</phase>
- <goals>
- <goal>install</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>default-resources</id>
- <phase>process-resources</phase>
- <goals>
- <goal>resources</goal>
- </goals>
- </execution>
- <execution>
- <id>default-testResources</id>
- <phase>process-test-resources</phase>
- <goals>
- <goal>testResources</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.12.4</version>
- <executions>
- <execution>
- <id>default-test</id>
- <phase>test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.2</version>
- <executions>
- <execution>
- <id>default-war</id>
- <phase>package</phase>
- <goals>
- <goal>war</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.7</version>
- <executions>
- <execution>
- <id>default-deploy</id>
- <phase>deploy</phase>
- <goals>
- <goal>deploy</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <version>3.3</version>
- <executions>
- <execution>
- <id>default-site</id>
- <phase>site</phase>
- <goals>
- <goal>site</goal>
- </goals>
- <configuration>
- <outputDirectory>C:\Users\LCore\git\debug\debug\target\site</outputDirectory>
- <reportPlugins>
- <reportPlugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </reportPlugin>
- </reportPlugins>
- </configuration>
- </execution>
- <execution>
- <id>default-deploy</id>
- <phase>site-deploy</phase>
- <goals>
- <goal>deploy</goal>
- </goals>
- <configuration>
- <outputDirectory>C:\Users\LCore\git\debug\debug\target\site</outputDirectory>
- <reportPlugins>
- <reportPlugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </reportPlugin>
- </reportPlugins>
- </configuration>
- </execution>
- </executions>
- <configuration>
- <outputDirectory>C:\Users\LCore\git\debug\debug\target\site</outputDirectory>
- <reportPlugins>
- <reportPlugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- </reportPlugin>
- </reportPlugins>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <outputDirectory>C:\Users\LCore\git\debug\debug\target\site</outputDirectory>
- </reporting>
- </project
測试
经过一些努力最终配置好了springmvc,以下进行一个简单的登录測试。
LoginController:
- package com.ceis.core.controller.login;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.servlet.ModelAndView;
- import com.ceis.core.controller.BaseController;
- import com.ceis.core.po.User;
- import com.ceis.core.service.UserService;
- @Controller
- public class LoginController extends BaseController{
- @Resource(name="userService")
- private UserService userService;
- @RequestMapping("/login")
- public ModelAndView login(User user,HttpServletRequest request,HttpServletResponse response)
- {
- ModelAndView view = null;
- user.setPassword(request.getParameter("password"));
- user.setName(request.getParameter("username"));
- if(userService.login(user.getName(),user.getPassword())){
- view = createLayoutView("content");
- request.getSession().setAttribute("user", user);
- return view;
- }
- else
- return new ModelAndView("login");
- }
- /**
- * 退出登录必须清空session
- * @param user
- * @param request
- * @return the login.jsp
- */
- @RequestMapping("/loginOut")
- public String loginOut(User user,HttpServletRequest request)
- {
- HttpSession httpSession = request.getSession();
- httpSession.removeAttribute("user");
- httpSession.invalidate();//session不可用
- return "redirect:login.jsp";//请求重定向到首页
- }
- }
登录页面的核心代码:
- <!-- Login Screen -->
- <div class="login-wrapper">
- <div class="login-container">
- <img width="100" height="30" src="resources/images/logo-login-big.png" />
- <form action="login" method="post">
- <div class="form-group">
- <input class="form-control" placeholder="用户名"
- type="text" name="username">
- </div>
- <div class="form-group">
- <input class="form-control" placeholder="password" type="password" name="password"><input
- type="submit" value="">
- </div>
- <div class="form-options clearfix">
- <a class="pull-right" href="#">忘记password?</a>
- <div class="text-left">
- <label class="checkbox"><input type="checkbox"><span>记住password</span></label>
- </div>
- </div>
- </form>
- <div class="social-login clearfix">
- <a class="btn btn-primary pull-left facebook" href=""><i
- class="icon-facebook"></i>Facebook login</a><a
- class="btn btn-primary pull-right twitter" href=""><i
- class="icon-twitter"></i>Twitter login</a>
- </div>
- <p class="signup">
- 没有账户? <a href="signup">马上注冊</a>
- </p>
- </div>
- </div>
点击登录之后顺利跳转至主页:

Eclipse Maven构建Spring MVC项目的更多相关文章
- 用maven创建Spring MVC项目
用maven创建Spring MVC项目 mvn archetype:generate -DgroupId=fry-arthur -DartifactId=spring-mvc-study -Darc ...
- 使用maven, myeclipse工具构建spring mvc项目
一.使用myeclipse 创建一个新的 maven项目. (ps:1.在filter过滤的时候输入 webapp 选择"maven-archetype-webapp". 2.在m ...
- IDEA 通过Maven创建Spring MVC项目搭建
概述 本篇随笔主要记录内容如下: 1.通过Maven创建基于Spring Framework类库的MVC项目,免去了繁琐的XML配置: 2.在Idea里面配置Tomcat的测试启动项: Maven创建 ...
- 使用maven一步一步构建spring mvc项目
1 使用eclipse构建maven web项目 1.1新建Maven的web项目 打开菜单File –New-MavenProject. 点击Next 选择模板类型archtype——ma ...
- 安装eclipse版本oxygen,及maven导入spring mvc项目并运行
本文地址为:http://www.cnblogs.com/jying/p/7511598.html 系统环境: win10 eclipse版本:2017.09.11 官网下载版本号为 oxygen 1 ...
- eclipse maven 构建简单springmvc项目
环境:eclipse Version: Oxygen.3a Release (4.7.3a) 创建maven Project项目,目录结构 修改工程的相关编译属性 修改pop.xml,引入spring ...
- maven web+spring mvc项目没有出现src/main/java路径
直接在main 文件夹下创建java可以解决 https://www.cnblogs.com/zhujiabin/p/6343462.html
- maven 纯注解一步一步搭建Spring Mvc项目(入门)
初次接触spring MVC项目,通过一段时间的学习,本文介绍一种以纯注解的方法去配置spring MVC环境,让那些配置的.xml文件统统见鬼吧. 什么是Spring MVC Spring MVC属 ...
- 第一个使用Spring Tool Suite(STS)和Maven建立的Spring mvc 项目
一.目标 在这篇文章中.我将要向您展示怎样使用Spring Frameworks 和 Maven build创建您的第一个J2ee 应用程序. 二.信息 Maven是一个java项目的构建工具(或者自 ...
随机推荐
- Ubuntu12.04编译Android4.0.1源码全过程-----附wubi安装ubuntu编译android源码硬盘空间不够的问题解决
昨晚在编译源码,make一段时间之后报错如下: # A fatal error has been detected by the Java Runtime Environment: # # SIGSE ...
- msyql在查询字段中的所有记录,不重复
mysql> select * from a ; +----+------+--------------+ | id | name | descri | +----+------+ ...
- SqlServer表EXCEL数据复制的另一种方法
一个.SqlServer表中的数据复制到excel 1.新建查询,用sql语句把表数据读出来 2.然后,选择数据,右键.复制(也能够点击连同标题复制),拷贝到记事本中(不然会乱码) 3.然后再把记事本 ...
- Test SRM Level Three: LargestCircle, Brute Force
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=3005&rd=5858 思路: 如果直接用Brute F ...
- 解决编译时出错提示: 'error: array must be initialized with a brace-enclosed initializer' 的错误
编译出现这个错误的原因非常简单编译的标准不相同.如果用stdc90,这个就可以直接编译通过了. 下面是代码例子: ...... ] = NULL;或者 :char cmd[256] = '\0'; . ...
- OTN&互换amp; P-OTN有效降低100G 网络成本 (两)
OTN互换& P-OTN有效降低100G 网络成本 (两) 在全球范围内.网流量的增长速度是空前的,导致此现象的缘由包含云服务的增长.移动宽带和基于互联网的视频点播服务的增长. Cisco估计 ...
- ECG信号读出,检测QRS,P,T 波(小波去噪,并根据检测),基于BP辨识的神经网络
这学期的课程选择神经网络.最后的作业处理ECG信号,并利用神经网络识别. 1 ECG引进和阅读ECG信号 1)ECG介绍 详细ECG背景应用就不介绍了,大家能够參考百度 谷歌.仅仅是简单说下ECG ...
- Eclipse在Jar形成和应用程序包
最近的熟悉Java语言.在学习过程中Eclipse经常使用再熟悉它.本文简单说下Jar形成和应用程序包. Java在Jar相当于包C/C++该lib库,它是.class文件打包:经常使用Jar包有AP ...
- ZOJ 1203 Swordfish 旗鱼 最小生成树,Kruskal算法
主题链接:problemId=203" target="_blank">ZOJ 1203 Swordfish 旗鱼 Swordfish Time Limit: 2 ...
- telnet发电子邮件
无聊今天的工作,想想一个学生被提到最后一次telnet发电子邮件,所以我想试试.最后,成功的实践,这里做个总结. 首先,cmd进telnet打开回话: 下面红色字体为命令. 1.open smtp.1 ...