ssh环境搭建(1.1)-lib maven 篇

来源:互联网 发布:mil域名 编辑:程序博客网 时间:2024/05/16 15:43

自己找lib搭建感觉还是有点low,毕竟大家都用 maven了,今天也小试了一把maven


maven 环境搭建比较简单,网上一大把。

我下载的eclipse 已经自己集成好maven了。直接下一步。

直接新建 maven 项目,然后选择webapp 就好了。


接下来要做的主要就是 写

pom.xml(jar包依赖关系了)


这里推荐网站 http://mvnrepository.com/ 知道要用什么jar 包就直接搜索就行了。

结果类似:


然后 复制到pom.xml 文件中 就好了,eclipse 就帮你自动去下载依赖的jar包了(第一次),如果有的话就会直接加载


剩下的就是一个一个找了,在pom文件中找到需要的jar包依赖就行。


有些 jar包是直接有依赖关系,比如 


<span style="white-space:pre"></span><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>5.1.0.Final</version></dependency>

直接把 

\hibernate-release-5.1.0.Final\lib\required 里边的包都导入了,不用一个一个导里边的包了。


最后贴上pom.xml  ( http://blog.csdn.net/flyjiangs/article/details/51610858 )里边的jar包基本一样了。

<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>mv-web-test</groupId><artifactId>caroamaven</artifactId><packaging>war</packaging><version>0.0.1-SNAPSHOT</version><name>caroamaven</name><url>http://maven.apache.org</url><properties><spring.version>4.2.6.RELEASE</spring.version><hibernate.version>5.1.0.Final</hibernate.version><struts.version>2.5</struts.version></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.8.1</version><scope>test</scope></dependency><!-- struts --><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-core</artifactId><version>${struts.version}</version></dependency><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-spring-plugin</artifactId><version>${struts.version}</version></dependency><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-convention-plugin</artifactId><version>${struts.version}</version></dependency><dependency><groupId>org.apache.struts</groupId><artifactId>struts2-json-plugin</artifactId><version>${struts.version}</version></dependency><!--hibernate --><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>${hibernate.version}</version></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-ehcache</artifactId><version>${hibernate.version}</version></dependency><dependency><groupId>com.mchange</groupId><artifactId>c3p0</artifactId><version>0.9.2.1</version></dependency><dependency><groupId>net.sf.ehcache</groupId><artifactId>ehcache</artifactId><version>2.10.1</version></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-entitymanager</artifactId><version>${hibernate.version}</version></dependency><!-- spring --><dependency><groupId>org.springframework</groupId><artifactId>spring-aop</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-aspects</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-context-support</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>${spring.version}</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-expression</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-orm</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>3.2.4.RELEASE</version><scope>compile</scope></dependency><dependency><groupId>org.apache.tomcat</groupId><artifactId>tomcat-servlet-api</artifactId><version>7.0.69</version><scope>provided</scope></dependency><dependency><groupId>javax.servlet.jsp</groupId><artifactId>jsp-api</artifactId><version>2.2</version><scope>provided</scope></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.18</version></dependency></dependencies><build><finalName>caroamaven</finalName></build></project>

然后把之前的项目迁移到maven里边。

放入tomcat运行

没有错误,数据正常显示。


搞定了,收工。

ps:maven 是个好东西,不用去网上直接找lib包了,lib各种下载不了,有的有毒,有的要分。 



0 0
原创粉丝点击