java集成开发环境常用操作集

时间:2023-01-08 18:57:53

1、简单搭建maven集成开发环境

一、     Jetty安装

下载地址(包涵windows和Linux各版本,Jetty9需要JDK7):http://download.eclipse.org/jetty/

Jetty安装非常简单,只需要解压安装包即可启动Jetty服务。

JETTY_VERSION=xxx

wget http://download.eclipse.org/jetty/$JETTY_VERSION/dist/jetty-distribution-$JETTY_VERSION.tar.gz

tarxfz jetty-distribution-$JETTY_VERSION.tar.gz

cd jetty-distribution-$JETTY_VERSION

java-jar start.jar

Jetty的简单测试(我们用Jetty8):

java集成开发环境常用操作集

test.war模块里面有一个dump的Servlet,它可以查看当前请求的Request/Session/Cookie信息。http://c909511:8080/dump/info这里面返回信息非常丰富,后续可以使用此方法调试当前请求信息:

java集成开发环境常用操作集

二、     Jetty与Eclipse集成

1、 下载Eclipse工具:

http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/luna/SR1/eclipse-jee-luna-SR1-win32-x86_64.zip

2、  安装Jetty组件

java集成开发环境常用操作集

java集成开发环境常用操作集

3、  配置Jetty

java集成开发环境常用操作集

java集成开发环境常用操作集

4、  配置完成后启动Jetty服务

java集成开发环境常用操作集

三、Maven与Eclipse集成

1、 下载Maven工具http://maven.apache.org/download.html

2、 安装Maven Integration for Eclipse插件

java集成开发环境常用操作集

3、  安装Maven;

a)         解压Maven到本地目录,设置环境变量;

i.              MAVEN_HOME为:D:/tools/apache-maven-3.2.1,将bin设置到PATH,在PATH末尾添加:;%MAVEN_HOME%/bin;

ii.              测试MAVEN是否设置成功,在Windows终端输入:mvn –v

java集成开发环境常用操作集

b)         设置Maven本地仓库

i.              在D:\tools\apache-maven-3.2.1\conf\settings.xml文件中修改localRepository节点值为D:\study\maven\jar,制定本地仓库地址;

java集成开发环境常用操作集

ii.              配置本地仓库nexus(可选)

Nexus下载地址:http://download.sonatype.com/nexus/oss/nexus-2.5.1-bundle.zip

安装Nexus只需解压配置即可运行

配置Nexus服务

java集成开发环境常用操作集

启动Nexus服务(如果运行提示拒绝访问,右键-》管理员身份运行)

java集成开发环境常用操作集

登陆Nexus

java集成开发环境常用操作集

配置Nexus中心仓库

java集成开发环境常用操作集

Nexus+Maven配置

java集成开发环境常用操作集

<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>Nexus Mirror</name>
<url>http://maven.oschina.net/content/groups/public</url>
</mirror> </mirrors> <profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8082/nexus/content/groups/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8082/nexus/content/groups/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles> <!-- activeProfiles
| List of profiles that are active for all builds.
|
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>
-->
<!--激活配置-->
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>

4、  eclipse配置Maven;

a)         设置Maven的Installations

java集成开发环境常用操作集

b)         设置Maven的User Settings

java集成开发环境常用操作集

5、  导入项目工程

a)         在Myeclipse中选择import…依次导入项目工程;

java集成开发环境常用操作集

b)         设置启动各个工程的Maven构建

java集成开发环境常用操作集

c)         完成环境搭建,启动看效果

java集成开发环境常用操作集

--------开发环境准备完毕end------------------------------

2、maven常用操作

a、引入项目中的jar包(使用这种方式引入的JAR包在打包时不会一起打包,所以打包后找不到该JAR包)

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>0.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/test.jar</systemPath>
</dependency>

打包引用包处理方法

<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>0.3</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/src/main/resources/lib/test.jar</systemPath>
</dependency>