maven nexus 最佳实践

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>org.jixiuf</groupId>
<artifactId>app</artifactId>
<packaging>jar</packaging>
<version>3.0</version>
<name>app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- distributionManagement 用于向nexus 服务器上deploy ;;;;; mvn deploy -->
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>



~/.m2/settings.xml


view plain
<settings>
<localRepository>/resource/java/repos/maven-repo</localRepository>
<mirrors>
<mirror>
<id>nexus</id>
<name>local private nexus</name>
<mirrorOf>central</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<servers>
<server>
<!--远程nexus 服务器的用户名与密码,作用就是当要向nexus deploy 自已写的jar 时,会用到.在pom.xml 中会有distributionManagement ,在那里会引用此处的id -->
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<!--上面定义了两个名为nexus nexus-snapshots的profile ,这里无条件激活激活, 也就是所有的项目都会用到到 ,这两个库
还有一种作用相同的用法,就是定义mirrors
-->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>





web tomcat 启动

mvn tomcat:run

除了这个好像还有一个 tomcat 的插件 ,不要弄错了,

<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>




<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>org.jixiuf</groupId>
<artifactId>web1</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>web1 Maven Webapp</name>
<url>http://maven.apache.org</url>
<build>
<finalName>webapp1</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>



======================================================================

一个s2sh 的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>org.jixiuf</groupId>
<artifactId>ss</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>ss Maven Webapp</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<!-- 编译源码 jdk 级别 -->
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<!-- mvn tomcat:run 运行tomcat -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
</configuration>
</plugin>
<plugin>
<!-- 与 hibernate 代码自动化相关的 -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<!-- 由hbm.xml 文件 或者annotation 生成 sql 语句 ,
因为hbm2ddl 是写在executions 中的,并且与process-classes进行了关联 ,
就是说在process-classes时也会进行hbm2ddl
-->
<goal>hbm2ddl</goal>
</goals>
</execution>
</executions>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>

<component>
<!--由 hbm 生成pojo domain 对象 -->
<name>hbm2java</name>
<packagename>${package.pojo}</packagename>

<outputDirectory>${src.dir}</outputDirectory>

</component>
<component>
<name>hbm2dao</name>
<packagename>${package.dao}</packagename>
<outputDirectory>${src.dir}</outputDirectory>
</component>
<component>
<name>hbmdoc</name>
</component>
</components>
<componentProperties>
<!-- 此plugin 一般性的属性配置 ,可以在component 中配置相同的元素override 这里的配置 -->
<configurationfile>/target/classes/hibernate.cfg.xml</configurationfile>
<packagename>org.jixiuf.pojo</packagename>
<outputfilename>schema.sql</outputfilename>
<jdk5>true</jdk5>
<scan-classes>true</scan-classes>
<!--
<namingstrategy>mycompany.myapp.IRDNamingStrategy</namingstrategy>
-->
<drop>false</drop>
<create>true</create>
<export>false</export>
<format>true</format>
</componentProperties>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.11</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.8.1</version>
</dependency>
<dependency>
<groupId>jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>3.7.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.7.ga</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<!-- 引入 servlet jsp 支持,否则 找不到httpServlet 等 类 -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.4_spec</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jsp_2.0_spec</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>

</dependencies>

<!-- 一些属性的配置 ,有上面可以${package.pojo} 引用这里的参数-->
<properties>
<package.pojo>org.jixiuf.pojo</package.pojo>
<package.dao>org.jixiuf.dao</package.dao>
<src.dir>/src/main/java</src.dir>
</properties>
</project>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值