Location of catalog files The Archetype Plugin knows by default about its internal catalog. It also knows about the local and remote catalogs.
local represents the ~/.m2/archetype-catalog.xml catalog file.
remote represents the https://repo.maven.apache.org/maven2/archetype-catalog.xml catalog file.
The Archetype Plugin can also read catalogs from filesystem/HTTP by providing the path/URL of a catalog file or of a directory containing an archetype-catalog.xml file.
How does the Archetype Plugin know about archetypes?
mvn -f /path/to/pom.xml
参照maven官方文档,默认会从两个路径加载settings配置文件
1.The Maven install: ${maven.home}/conf/settings.xml
2.A user’s install: ${user.home}/.m2/settings.xml
可以将自己定制的配置覆盖到上述两个路径,这样执行mvn的时候就不需要通过-s来指定settings的路径了
参考:
Security and Deployment Settings
<distributionManagement>
<repository>
<id>my-releases-repository</id>
<url>http://127.0.0.1/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>my-snapshots-repository</id>
<url>http://127.0.0.1/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<servers>
<server>
<id>my-releases-repository</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>my-snapshots-repository</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
然后在项目根目录执行mvn deploy
即可完成发布,其他对该项目有依赖的项目就可以通过dependency依赖到该发布结果了。
主要原因是jetty会使用内存映射文件来缓存静态文件
配置文件在org.eclipse.jetty.webapp下的webdefault.xml有如下说明
* useFileMappedBuffer * If set to true, it will use mapped file buffer to serve static content * when using NIO connector. Setting this value to false means that * a direct buffer will be used instead of a mapped file buffer. * By default, this is set to true.
参考文章中的解决方法是在pom.xml文件中将
implementation=”org.eclipse.jetty.server.nio.SelectChannelConnector”>替换为
implementation=”org.eclipse.jetty.server.bio.SocketConnector”>
修改前
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<stopKey>stop</stopKey>
<stopPort>5599</stopPort>
<webAppConfig>
<contextPath>/</contextPath>
<defaultsDescriptor></defaultsDescriptor>
</webAppConfig>
<scanIntervalSeconds>5</scanIntervalSeconds>
<connectors>
<connector
implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
修改后
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<stopKey>stop</stopKey>
<stopPort>5599</stopPort>
<webAppConfig>
<contextPath>/</contextPath>
<defaultsDescriptor></defaultsDescriptor>
</webAppConfig>
<scanIntervalSeconds>5</scanIntervalSeconds>
<connectors>
<connector
implementation="org.eclipse.jetty.server.bio.SocketConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
</plugin>
环境:centos 7 minimal 64位+jdk 8+maven3.3.3+git2.5.0
yum install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel.x86_64 -y
git clone git@github.com:sonatype/nexus-public.git
进入nexus目录,执行./mvnw clean install
,等待网速慢的时候时间较长
进入target/nexus-**/bin 执行./nexus start
完成启动,按ctrl+c然后输入shutdown可以完成关闭
访问http://localhost:8081/进入管理界面
可以通过修改 target/nexus-**/etc/org.sonatype/.nexus.cfg文件设置端口
dependencies中增加dependency节点
dependencyManagement>dependencies中增加dependency节点
例如导入sqlserver驱动包如下:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/sqljdbc4.jar</systemPath>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.4.0</version>
</dependency>
</dependencies>
</dependencyManagement>