Mac下maven工程的创建,并搭建SSH环境
最近项目有用到maven,就特地学了一下。maven的一句话攻略就是,项目托管。帮你解决各种项目琐事:清理,导包....等等。
首先先到apach官网去下载一个maven的包,http://maven.apache.org/download.cgi
解压了之后,打开终端。输入:
cd ~
vim .bash_profile
在文本里输入
最后保存后输入
source .bash_profile
然后打开eclipse的偏好设置。
创建maven工程,在其中一步中选择
创建完后直接run就可以了,应该是新版特性。
- 搭建ssh环境
maven工程搭建比较方便,但是下载依赖的时候会很久。
配置ssh在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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>webapp</groupId> <artifactId>MavenApp</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>MavenApp Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- Struts2 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.3.1</version> </dependency> <!-- 添加Hibernate依赖 --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.6.5.Final</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <!-- 添加Log4J依赖 --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-nop</artifactId> <version>1.6.4</version> </dependency> <!-- 添加javassist --> <dependency> <groupId>javassist</groupId> <artifactId>javassist</artifactId> <version>3.11.0.GA</version> </dependency> <!-- 添加Spring依赖 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.1.1.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.1.1.RELEASE</version> </dependency> <!-- convention-plugin插件,使用了这个插件之后,就可以采用注解的方式配置Action --> <!-- Struts2和Spring整合插件 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>2.3.4.1</version> </dependency> </dependencies> <build> <finalName>MavenApp</finalName> </build> </project>
等它下载完之后,在resource中创建struts.xml,spring.xml等配置文件,并配置web.xml
struts.xml中写入如下
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true" /> <!-- submit不换行 --> <constant name="struts.ui.theme" value="simple" /> <constant name="struts.i18n.encoding" value="UTF-8"/> <!--整合spring--> <constant name="struts.objectFactory" value="spring" /> <!-- Add packages here --> <package name="default" namespace="/" extends="struts-default"> <!-- 测试action--> <!-- class对应applicationContext.xml的id,在applicationContext.xml上配置真是路径 --> <action name="hel" class="Hello"> <result name="success"></result> </action> </package> </struts>
spring.xml中写入
<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:util="http://www.springframework.org/schema/util" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd" default-lazy-init="true"> <bean id="Hello" class="action.TestAction"> </bean> </beans>
web.xml中配置如下
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance http://www.springmodules.org/schema/cache/springmodules-cache.xsd " xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>MavenApp</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <init-param> <param-name>config</param-name> <param-value>classpath:struts.xml</param-value> </init-param> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <!-- Struts2过滤器拦截所有的.action请求 --> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation </param-name> <param-value>classpath:spring/spring.xml</param-value> </context-param> </web-app>
最后访问http://localhost:8080/MavenApp/hel
值得注意的是,bean的路径直接把java下的包带入即可
Mac下maven工程的创建,并搭建SSH环境的更多相关文章
- idea/eclipse下Maven工程集成web服务(tomcat、jetty)
idea/eclipse下Maven工程集成web服务 转载请注明出处:http://www.cnblogs.com/funnyzpc/p/8093554.html 应用服务器最常用的一般有这哥仨: ...
- Mac下Maven安装与配置
Mac下Maven安装与配置 下载maven http://maven.apache.org/download.cgi main->download菜单下的Files 下载后解压在Documen ...
- 搭建SSH环境之添加所需jar包
一.首先介绍要添加框架环境: JUnit Struts2 Hibernate Spring (1)配置JUnit /**-------------------------添加JUnit-------- ...
- 条理清晰的搭建SSH环境之整合Struts和Spring
上文说到搭建SSH环境所需三大框架的jar包,本篇博客将通过修改配置文件整合Struts和Spring,下篇博客整合Hibernate和Spring即可完成环境搭建. 1.声明bean,新建TestA ...
- Linux Ubuntu从零开始部署web环境及项目-----搭建ssh环境(一)
linux搭建ssh环境 1,用户登录 成功输入用户名和密码后 进入Ubuntu界面 2,配置网络 参考:http://blog.csdn.net/liu782726344/article/deta ...
- 淘淘商城maven工程的创建和svn的上传实现
后台管理系统工程结构 maven管理的好处 1.项目构建.Maven定义了软件开发的整套流程体系,并进行了封装,开发人员只需要指定项目的构建流程,无需针对每个流程编写自己的构建脚本. 2.依赖管理.除 ...
- 解决maven工程无法创建src/main/java包名的方法
我的maven工程不知道为什么无法创建src/main/java这样的包,我创建好的maven工程只有src/main/resources包,其他的主要包都没有,而且不能创建包,new出来的包都是一个 ...
- Mac下Maven的删除和安装
一 删除maven 找到当前的maven路劲:使用mvn -v查看当前maven的安装目录在哪 删掉sudo rm -rf [maven的路径] 二 安装maven 1.下载maven压缩包 mac下 ...
- mac下用clion进行sdl2游戏开发de环境搭建
1. 故事背景 想从unity转unreal了,于是要使用c++进行开发.unreal引擎那么大,每次打开,我的小本都嗡嗡嗡的,想着不如用个轻量一些的引擎先开发吧,核心代码独立出来,到时候如果真要移植 ...
随机推荐
- 用AVFoundation自定义相机拍照
自定义拍照或者录视频的功能,就需要用到AVFoundation框架,目前我只用到了拍照,所以记录下自定义拍照用法,视频用法等用上了再补充,应该是大同小异 demo在这里:https://github. ...
- Android无需申请权限拨打电话
Android打电话有两种实现方法: 第一种方法,拨打电话跳转到拨号界面.源代码如下: Intent intent = new Intent(Intent.ACTION_DIAL); Uri data ...
- Eclipse中JAR System library 没有怎么添加?
1.打开 >> Eclipse 2.右击项目 >> Build path >> Configure Build path 如图1: 图1 3.进入 ...
- MySQL 博客文章目录(2016-08-20更新)
1 MySQL安装配置 Linux MySQL源码安装缺少ncurses-devel包 Linux平台卸载MySQL总结 Linux 卸载mysql-libs包出现错误 2 MySQL管理配置 My ...
- [MySQL Reference Manual] 24 MySQL sys框架
24 MySQL sys框架 24 MySQL sys框架 24.1 sys框架的前提条件 24.2 使用sys框架 24.3 sys框架进度报告 24.4 sys框架的对象 24.4.1所有sys下 ...
- problems during rovio build
1. rovio的readme中使用的是catkin build, ROS tutorial中用的是catkin_make. 关于build与make的区别: build重新编译所有文件:make默认 ...
- node 异步回调解决方法之yield
先看如何使用 使用的npm包为genny,npm 安装genny,使用 node -harmony 文件(-harmony 为使用es6属性启动参数) 启动项目 var genny= require( ...
- 新手!mass 设置问题
mass就是你那个物体的质量啊质量越大,惯性也越大重力也越大.假如你的刚体的mass为1,那么你只要给这个物体9.81N向上的力,你就可以抵消重力,让这个物体悬浮着:但假如这个物体的mass为10,你 ...
- fail树
前置技能:AC自动机 假设我们有了一个AC自动机,然后在上面进行字符串匹配. 上面是一个有四个字符串的AC自动机(abcde.aacdf.cdf.cde),虚线是fail指针,实线是转移. 这是上一次 ...
- [LeetCode] Binary Watch 二进制表
A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom ...