<!-- dmo通常定义bean commons里面通常定义工具类 biz里面是业务逻辑 provider是对外开放的接口 main是服务的启动 鉴于代码如此分布,依赖关系通常也是按此顺序,因此在modules中定义模块,须要根据依赖顺序安排前后 --> <modules>
<module>service-outgate-dmo</module>
<module>service-outgate-commons</module>
<module>service-outgate-biz</module>
<module>service-outgate-provider</module>
<module>service-outgate-main</module>
</modules>
<!-- 模块之间存在依赖关系,须要弄清楚模块之间的依赖顺序,编译的时候被依赖者放到modules元素中的靠前位置。 模块若是互相依赖,要注意编译顺序。 尽可能避免模块之间的循环依赖 --> <modules>
<module>service-video-dmo</module>
<module>service-video-commons</module>
<module>service-video-biz</module>
<module>service-video-provider</module>
<module>service-video-main</module>
</modules>
<!-- maven多级项目,须要考虑同级父项目的子项目间的依赖关系,并行开发的服务,最好中间不要产生依赖。 不一样业务的请求和响应对象,在分项目的时候,不一样业务以前的bean尽可能不要产生依赖。子项目间的复杂 依赖关系,后致使后期项目编译依赖过于繁琐。致使pom文件的依赖很差定义,会使之往更糟糕的方向发展。 --> <modules>
<module>service-user</module>
<module>service-outgate</module>
<module>service-video</module>
<module>service-msg</module>
</modules>
以上可能出现的问题就是,编译找不到类的方法。web
在Nexus中依赖有pom没有jar,通常pom里面都是有jar的地址信息,maven去下载的时候下载不下来,多是由于网络,多是由于jar服务提供上收费,这种状况下,通常建议本地安装jar到Nexus,不到第三方下载,将jar安装在Nexus的thirtyParty目录apache
${basedir} 项目根目录 bash
${project.build.directory} 构建目录,缺省为target 网络
${project.build.outputDirectory} 构建过程输出目录,缺省为target/classes maven
${project.build.finalName} 产出物名称,缺省为${project.artifactId}-${project.version} 编辑器
${project.packaging} 打包类型,缺省为jar ide
${project.xxx} 当前pom文件的任意节点的内容 工具
Profile为不一样的环境能够配置不一样的打包要求,在profile中能够覆盖pom中的几乎全部元素。在打包运行的时候须要在命令行传参指定运行那个Profile,这个参数就是profile的id.测试
<profile>
<id>local</id>
<properties>
<context.conf.path>classpath:config/properties/config_local.properties</context.conf.path>
</properties>
<activation> <activeByDefault>true</activeByDefault> </activation> </profile>
<profile>
<!-- 开发环境 --> <id>dev</id>
<properties>
<context.conf.path>classpath:config/properties/config_dev.properties</context.conf.path>
</properties>
</profile>
<profile>
<!-- 测试环境 --> <id>test</id>
<properties>
<context.conf.path>classpath:config/properties/config_test.properties</context.conf.path>
</properties>
</profile>
</profiles>
假如打包本地环境,命令为:ui
mvn clean install –Plocal
此种方式,是手动激活,指定运行某种环境构建。
能够经过在profile中配置激活策略,当构建环境知足某些构建策略时,进行某个profile的构建。激活配置放在上面加粗标红的元素里。
Profile能够单独成立文件,引入到pom。也能够在私服的settings.xml中设置全局的profile,被全部项目共享。
pluginManagerment通常使用在父pom中,用来管理全部子项目须要用到的插件。在父pom中,声明插件全部的基本信息(版本号,JDK版本等等),在子pom中使用使用插件只需groupId,artifactId便可,无需配置其余的额外信息,这样能够作到全部子项目使用一样的插件配置。若是子项目,须要使用不一样的参数配置,在子pom中能够自行声明。
在父pom中管理全部子项目可能须要使用到的插件,子项目不声明使用父pom中的插件,则子项目就不会用到该插件。
父pom中的配置:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
子pom中的配置:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
pluginManagement里只是声明依赖,并不实现引入,所以子项目须要显式的声明须要用的依赖。Plugins则相反,声明的都会引入。
Dependencys和dependencyManager是同同样的道理。
要找出文件乱码的根源,就须要知道编码的流程。从编写文件到打成发布包,中间经历几回转码。
首先编写文件,编辑器或IDE会默认为文件指定编码。
其次文件会通过编译器编译,不过配置文件,应该不会被编译器处理。
Copy文件到要打的包中,这个过程maven是怎么获取编码方式的,默认取机器编码,仍是获取项目文件编码,或者是在pom文件中指定编码变量供其读取使用。
Maven获取编码的顺序应该是:
若是为指定project.build.sourceEncoding编码,maven使用默认,指定则使用指定。插件也能够指定编码,若是插件指定了编码,则使用插件自身指定的编码。
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<configuration>
<encode>utf-8</encode>
</configuration>
在以前的版本中关闭防火墙等服务的命令是
service iptables stop
/etc/init.d/iptables stop
在RHEL7中,其实没有这个服务
[root@rhel7 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)
[root@rhel7 ~]# service iptables stop
Redirecting to /bin/systemctl stop iptables.service
[root@rhel7 ~]# /etc/init.d/iptables stop
-bash: /etc/init.d/iptables: No such file or directory
原来在RHEL7开始,使用systemctl工具来管理服务程序,包括了service和chkconfig
systemctl list-unit-files|grep enabled
[root@rhel7 ~]# systemctl stop firewalld.service
[root@rhel7 ~]# systemctl disable firewalld.service
[root@rhel7 ~]# systemctl status firewalld.service
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $?
查看已启动的服务列表:systemctl list-unit-files|grep enabled
正常打包war项目时,只需标示项目打包类型便可实现web项目的war打包。可是项目不知为什么单独声明war-plugin,其指定的不一样属性致使打包的不一样类型。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>etopmiddle-oms-web</warName>
<!--是否将war项目打成jar包,若是设置为TRUE则将web项目打成jar,war中包含配置文件和lib, 设置为false,则是常规war--> <archiveClasses>false</archiveClasses>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory --> <directory>src/main/resources</directory>
<targetPath>WEB-INF/classes</targetPath>
<!-- the list has a default value of ** --> <includes>
<include>**</include>
</includes>
<filtering>true</filtering>
</resource>
</webResources>
</configuration>
</plugin>
以上即为项目中的war-plugin的声明。其意图很明显,是将war中的class文件打包成jar,而后在class的jar做为lib引用,war中只包含配置文件。可是这样打包,会引发配置文件的乱码。避免乱码的最好方式就是不使用非英文。注释掉该配置,项目打包恢复正常。