描述:Myeclipse新建maven项目,Select an Archetype列表为空
缘由:缺乏archetype文件
解决思路:经过mvn命令来建立项目骨架,这时maven会自动去更新而且下载archetype文件.html
mvn archetype:generate // 首先它会去下载依赖的jar文件, // 而后出现Generating project in interactive mode.(会等待较长时间,跟网速有关.) // 接在它会下载最新的http://repo1.maven.org/maven2/archetype-catalog.xml // 最后出现Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 909: // 这是提示你建立新项目骨架,这是能够直接退出命令行,重启myeclipse建立新项目了.
参考: http://blog.csdn.net/kingzone_2008/article/details/39621849
http://tieba.baidu.com/p/2804486258
http://www.cnblogs.com/yjmyzz/p/3495762.htmlapache
JVM内存过小了,从新设置一下Myeclipse的JVM内存,参考http://unixboy.iteye.com/blog/174173/app
dependencyManagement是声明本项目中可能会使用什么依赖,(能够用于版本统一管理)
dependencies是定义项目中使用什么依赖
当一个依赖出如今dependencyManagement中时dependencies中的定义就不须要版本号了eclipse
<!-- 声明项目用哪一个版本的junit --> <!-- 一般这个是放在 parent项目中的 --> <dependencyManagement> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency> </dependencies> </dependencyManagement>
<!-- 定义项目使用哪一个版本的junit --> <!-- 一般这些是定义在 子项目中的 --> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> <!-- 建议不要设置version值, 它会默认找management中的version --> <!-- 若是项目有特殊差别,能够在此定义当前项目中须要的版本 --> <!-- <version>3.8</version> --> </dependency> </dependencies>
注意:只有依赖被定义时maven才会将依赖添加到项目中maven
须要为resource设置filtering为true,这样才会将profile属性编译到resouce文件中工具
<!-- 若是你使用了pros,就须要显式定义resource,而且设置filtering --> <resources> <!-- resource 的具体状况请根据项目的路径来设定,这里只是参考 --> <resource> <!-- 主要是这个属性 --> <filtering>true</filtering> <directory>src/main/resources</directory> <!-- 若是不声明includes就表示目录下全部文件 --> <includes> <include>**/*</include> </includes> </resource> </resources>
5.1.肯定文件格式是utf-8
5.2.肯定配置文件显式声明为utf-8
5.3.pom设置project.build.sourceEncoding,以及设置maven-compiler-plugin的编码方式测试
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> ..... ..... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> <!--主要是这一句 --> <encoding>UTF-8</encoding> </configuration> </plugin>
这个问题参考地址:http://blog.csdn.net/chinazgr/article/details/48176089ui
思路,经过xml定义好不一样环境的配置参数,经过命令-P或者activeByDefault的参数来定义用哪套来打包.
6.1定义全部环境的配置参数编码
<!-- 能够经过mvn -P [ID 好比:mvn -PDEV install] 来使用 --> <profiles> <!-- 开发环境配置参数 --> <profile> <id>DEV</id> <!-- 默认使用它来打包 --> <activation><activeByDefault>true</activeByDefault></activation> <properties> <!-- 参数配置, 标签是你本身定义的 --> <mvncfg.log.path><![CDATA[F:/logs]]></mvncfg.log.path> </properties> </profile> <!-- 测试环境配置参数 --> <profile> <id>TEST</id> <!-- 若是想要打包测试环境,将上面的activation注释掉,而且copy到这里 --> <properties> <!-- 日志输出路径 --> <mvncfg.log.path><![CDATA[F:/test/logs]]></mvncfg.log.path> </properties> </profile> </profiles>
6.2告诉maven哪些文件须要使用这些参数来替换占位符,或者哪些文件不须要替换占位符spa
<!-- 全部你须要先定义哪些是资源文件 --> <resources> <resource> <!-- 这个是最关键的 --> <filtering>true</filtering> <directory>src/main/resources</directory> <includes> <include>**/*</include> </includes> <!-- 这个是为了排除部分不须要替换占位符,或者已有的占位符与maven占位符冲突的文件 --> <!-- 一般建议你避开一下maven自己自带的占位符,好比${id},这样就不须要定义排除了 --> <excludes> <exclude>config/execlude.xml</exclude> </excludes> </resource> <!-- execlude.xml原本是资源文件,只是不须要使用替换占位符而已 --> <!-- 因此这里还须要将execlude.xml声明为资源文件 --> <resource> <!-- 这个参数告诉maven不须要帮我替换占位符 --> <filtering>false</filtering> <directory>src/main/resources</directory> <includes> <include>config/execlude.xml</include> </includes> </resource> </resources>
6.3.使用占位符,(假设文件位置src/main/resources/properties/log4j.properties)
.... #若是打包开发者环境,他就是D:/logs/logfile.log #若是打包测试环境,他就是D:/logs/test/logfile.log log4j.appender.File.File =${mvncfg.log.path}/logfile.log ....
搜索备注:maven如何将配置信息打到某些包下,maven如何排除配置文件,maven的includes与excludes
7.1 方法有两种,1本身搭建私服,2.直接使用systemPath来指定(这就是我想说的)
<!-- 本地jar包 二维码相关工具 --> <dependency> <groupId>jp.sourceforge.qrcode</groupId> <artifactId>QRCode</artifactId> <version>1.0</version> <scope>system</scope> <!-- 在这里指定jar的路径就能够了,可是一般建议使用变量来配置,毕竟每一个人的路径不必定相同 --> <systemPath>${localJarPath}/QRCode.jar</systemPath> </dependency>
但愿能帮你解决问题
本文出处:https://my.oschina.net/longfong/blog/813146