原文:https://maven.apache.org/guides/introduction/introduction-to-the-pom.html

Introduction to the POM

What is a POM?

A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects. Examples for this is the build directory, which is target; the source directory, which is src/main/java; the test source directory, which is src/test/java; and so on.

The POM was renamed from project.xml in Maven 1 to pom.xml in Maven 2. Instead of having a maven.xml file that contains the goals that can be executed, the goals or plugins are now configured in the pom.xml. When executing a task or goal, Maven looks for the POM in the current directory. It reads the POM, gets the needed configuration information, then executes the goal.

Some of the configuration that can be specified in the POM are the project dependencies, the plugins or goals that can be executed, the build profiles, and so on. Other information such as the project version, description, developers, mailing lists and such can also be specified.

[top]

Super POM

The Super POM is Maven's default POM. All POMs extend the Super POM unless explicitly set, meaning the configuration specified in the Super POM is inherited by the POMs you created for your projects. The snippet below is the Super POM for Maven 2.0.x.

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <name>Maven Default Project</name>
  4. <repositories>
  5. <repository>
  6. <id>central</id>
  7. <name>Maven Repository Switchboard</name>
  8. <layout>default</layout>
  9. <url>http://repo1.maven.org/maven2</url>
  10. <snapshots>
  11. <enabled>false</enabled>
  12. </snapshots>
  13. </repository>
  14. </repositories>
  15. <pluginRepositories>
  16. <pluginRepository>
  17. <id>central</id>
  18. <name>Maven Plugin Repository</name>
  19. <url>http://repo1.maven.org/maven2</url>
  20. <layout>default</layout>
  21. <snapshots>
  22. <enabled>false</enabled>
  23. </snapshots>
  24. <releases>
  25. <updatePolicy>never</updatePolicy>
  26. </releases>
  27. </pluginRepository>
  28. </pluginRepositories>
  29. <build>
  30. <directory>target</directory>
  31. <outputDirectory>target/classes</outputDirectory>
  32. <finalName>${artifactId}-${version}</finalName>
  33. <testOutputDirectory>target/test-classes</testOutputDirectory>
  34. <sourceDirectory>src/main/java</sourceDirectory>
  35. <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
  36. <testSourceDirectory>src/test/java</testSourceDirectory>
  37. <resources>
  38. <resource>
  39. <directory>src/main/resources</directory>
  40. </resource>
  41. </resources>
  42. <testResources>
  43. <testResource>
  44. <directory>src/test/resources</directory>
  45. </testResource>
  46. </testResources>
  47. </build>
  48. <reporting>
  49. <outputDirectory>target/site</outputDirectory>
  50. </reporting>
  51. <profiles>
  52. <profile>
  53. <id>release-profile</id>
  54. <activation>
  55. <property>
  56. <name>performRelease</name>
  57. </property>
  58. </activation>
  59. <build>
  60. <plugins>
  61. <plugin>
  62. <inherited>true</inherited>
  63. <groupId>org.apache.maven.plugins</groupId>
  64. <artifactId>maven-source-plugin</artifactId>
  65. <executions>
  66. <execution>
  67. <id>attach-sources</id>
  68. <goals>
  69. <goal>jar</goal>
  70. </goals>
  71. </execution>
  72. </executions>
  73. </plugin>
  74. <plugin>
  75. <inherited>true</inherited>
  76. <groupId>org.apache.maven.plugins</groupId>
  77. <artifactId>maven-javadoc-plugin</artifactId>
  78. <executions>
  79. <execution>
  80. <id>attach-javadocs</id>
  81. <goals>
  82. <goal>jar</goal>
  83. </goals>
  84. </execution>
  85. </executions>
  86. </plugin>
  87. <plugin>
  88. <inherited>true</inherited>
  89. <groupId>org.apache.maven.plugins</groupId>
  90. <artifactId>maven-deploy-plugin</artifactId>
  91. <configuration>
  92. <updateReleaseInfo>true</updateReleaseInfo>
  93. </configuration>
  94. </plugin>
  95. </plugins>
  96. </build>
  97. </profile>
  98. </profiles>
  99. </project>

The snippet below is the Super POM for Maven 2.1.x.

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <name>Maven Default Project</name>
  4. <repositories>
  5. <repository>
  6. <id>central</id>
  7. <name>Maven Repository Switchboard</name>
  8. <layout>default</layout>
  9. <url>http://repo1.maven.org/maven2</url>
  10. <snapshots>
  11. <enabled>false</enabled>
  12. </snapshots>
  13. </repository>
  14. </repositories>
  15. <pluginRepositories>
  16. <pluginRepository>
  17. <id>central</id>
  18. <name>Maven Plugin Repository</name>
  19. <url>http://repo1.maven.org/maven2</url>
  20. <layout>default</layout>
  21. <snapshots>
  22. <enabled>false</enabled>
  23. </snapshots>
  24. <releases>
  25. <updatePolicy>never</updatePolicy>
  26. </releases>
  27. </pluginRepository>
  28. </pluginRepositories>
  29. <build>
  30. <directory>${project.basedir}/target</directory>
  31. <outputDirectory>${project.build.directory}/classes</outputDirectory>
  32. <finalName>${project.artifactId}-${project.version}</finalName>
  33. <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
  34. <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
  35. <!-- TODO: MNG-3731 maven-plugin-tools-api < 2.4.4 expect this to be relative... -->
  36. <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
  37. <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
  38. <resources>
  39. <resource>
  40. <directory>${project.basedir}/src/main/resources</directory>
  41. </resource>
  42. </resources>
  43. <testResources>
  44. <testResource>
  45. <directory>${project.basedir}/src/test/resources</directory>
  46. </testResource>
  47. </testResources>
  48. <pluginManagement>
  49. <plugins>
  50. <plugin>
  51. <artifactId>maven-antrun-plugin</artifactId>
  52. <version>1.3</version>
  53. </plugin>
  54. <plugin>
  55. <artifactId>maven-assembly-plugin</artifactId>
  56. <version>2.2-beta-2</version>
  57. </plugin>
  58. <plugin>
  59. <artifactId>maven-clean-plugin</artifactId>
  60. <version>2.2</version>
  61. </plugin>
  62. <plugin>
  63. <artifactId>maven-compiler-plugin</artifactId>
  64. <version>2.0.2</version>
  65. </plugin>
  66. <plugin>
  67. <artifactId>maven-dependency-plugin</artifactId>
  68. <version>2.0</version>
  69. </plugin>
  70. <plugin>
  71. <artifactId>maven-deploy-plugin</artifactId>
  72. <version>2.4</version>
  73. </plugin>
  74. <plugin>
  75. <artifactId>maven-ear-plugin</artifactId>
  76. <version>2.3.1</version>
  77. </plugin>
  78. <plugin>
  79. <artifactId>maven-ejb-plugin</artifactId>
  80. <version>2.1</version>
  81. </plugin>
  82. <plugin>
  83. <artifactId>maven-install-plugin</artifactId>
  84. <version>2.2</version>
  85. </plugin>
  86. <plugin>
  87. <artifactId>maven-jar-plugin</artifactId>
  88. <version>2.2</version>
  89. </plugin>
  90. <plugin>
  91. <artifactId>maven-javadoc-plugin</artifactId>
  92. <version>2.5</version>
  93. </plugin>
  94. <plugin>
  95. <artifactId>maven-plugin-plugin</artifactId>
  96. <version>2.4.3</version>
  97. </plugin>
  98. <plugin>
  99. <artifactId>maven-rar-plugin</artifactId>
  100. <version>2.2</version>
  101. </plugin>
  102. <plugin>
  103. <artifactId>maven-release-plugin</artifactId>
  104. <version>2.0-beta-8</version>
  105. </plugin>
  106. <plugin>
  107. <artifactId>maven-resources-plugin</artifactId>
  108. <version>2.3</version>
  109. </plugin>
  110. <plugin>
  111. <artifactId>maven-site-plugin</artifactId>
  112. <version>2.0-beta-7</version>
  113. </plugin>
  114. <plugin>
  115. <artifactId>maven-source-plugin</artifactId>
  116. <version>2.0.4</version>
  117. </plugin>
  118. <plugin>
  119. <artifactId>maven-surefire-plugin</artifactId>
  120. <version>2.4.3</version>
  121. </plugin>
  122. <plugin>
  123. <artifactId>maven-war-plugin</artifactId>
  124. <version>2.1-alpha-2</version>
  125. </plugin>
  126. </plugins>
  127. </pluginManagement>
  128. </build>
  129. <reporting>
  130. <outputDirectory>${project.build.directory}/site</outputDirectory>
  131. </reporting>
  132. <profiles>
  133. <profile>
  134. <id>release-profile</id>
  135. <activation>
  136. <property>
  137. <name>performRelease</name>
  138. <value>true</value>
  139. </property>
  140. </activation>
  141. <build>
  142. <plugins>
  143. <plugin>
  144. <inherited>true</inherited>
  145. <groupId>org.apache.maven.plugins</groupId>
  146. <artifactId>maven-source-plugin</artifactId>
  147. <executions>
  148. <execution>
  149. <id>attach-sources</id>
  150. <goals>
  151. <goal>jar</goal>
  152. </goals>
  153. </execution>
  154. </executions>
  155. </plugin>
  156. <plugin>
  157. <inherited>true</inherited>
  158. <groupId>org.apache.maven.plugins</groupId>
  159. <artifactId>maven-javadoc-plugin</artifactId>
  160. <executions>
  161. <execution>
  162. <id>attach-javadocs</id>
  163. <goals>
  164. <goal>jar</goal>
  165. </goals>
  166. </execution>
  167. </executions>
  168. </plugin>
  169. <plugin>
  170. <inherited>true</inherited>
  171. <groupId>org.apache.maven.plugins</groupId>
  172. <artifactId>maven-deploy-plugin</artifactId>
  173. <configuration>
  174. <updateReleaseInfo>true</updateReleaseInfo>
  175. </configuration>
  176. </plugin>
  177. </plugins>
  178. </build>
  179. </profile>
  180. </profiles>
  181. </project>

[top]

Minimal POM

The minimum requirement for a POM are the following:

  • project root
  • modelVersion - should be set to 4.0.0
  • groupId - the id of the project's group.
  • artifactId - the id of the artifact (project)
  • version - the version of the artifact under the specified group

Here's an example:

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. </project>

A POM requires that its groupId, artifactId, and version be configured. These three values form the project's fully qualified artifact name. This is in the form of <groupId>:<artifactId>:<version>. As for the example above, its fully qualified artifact name is "com.mycompany.app:my-app:1".

Also, as mentioned in the first section, if the configuration details are not specified, Maven will use their defaults. One of these default values is the packaging type. Every Maven project has a packaging type. If it is not specified in the POM, then the default value "jar" would be used.

Furthermore, as you can see that in the minimal POM, the repositories were not specified. If you build your project using the minimal POM, it would inherit therepositories configuration in the Super POM. Therefore when Maven sees the dependencies in the minimal POM, it would know that these dependencies will be downloaded from http://repo.maven.apache.org/maven2 which was specified in the Super POM.

[top]

Project Inheritance

Elements in the POM that are merged are the following:

  • dependencies
  • developers and contributors
  • plugin lists (including reports)
  • plugin executions with matching ids
  • plugin configuration
  • resources

The Super POM is one example of project inheritance, however you can also introduce your own parent POMs by specifying the parent element in the POM, as demonstrated in the following examples.

Example 1

The Scenario

As an example, let us reuse our previous artifact, com.mycompany.app:my-app:1. And let us introduce another artifact, com.mycompany.app:my-module:1.

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-module</artifactId>
  5. <version>1</version>
  6. </project>

And let us specify their directory structure as the following:

  1. .
  2. |-- my-module
  3. | `-- pom.xml
  4. `-- pom.xml

Note: my-module/pom.xml is the POM of com.mycompany.app:my-module:1 while pom.xml is the POM of com.mycompany.app:my-app:1

The Solution

Now, if we were to turn com.mycompany.app:my-app:1 into a parent artifact of com.mycompany.app:my-module:1,we will have to modify com.mycompany.app:my-module:1's POM to the following configuration:

com.mycompany.app:my-module:1's POM

  1. <project>
  2. <parent>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. </parent>
  7. <modelVersion>4.0.0</modelVersion>
  8. <groupId>com.mycompany.app</groupId>
  9. <artifactId>my-module</artifactId>
  10. <version>1</version>
  11. </project>

Notice that we now have an added section, the parent section. This section allows us to specify which artifact is the parent of our POM. And we do so by specifying the fully qualified artifact name of the parent POM. With this setup, our module can now inherit some of the properties of our parent POM.

Alternatively, if we want the groupId and / or the version of your modules to be the same as their parents, you can remove the groupId and / or the version identity of your module in its POM.

  1. <project>
  2. <parent>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. </parent>
  7. <modelVersion>4.0.0</modelVersion>
  8. <artifactId>my-module</artifactId>
  9. </project>

This allows the module to inherit the groupId and / or the version of its parent POM.

[top]

Example 2

The Scenario

However, that would work if the parent project was already installed in our local repository or was in that specific directory structure (parent pom.xml is one directory higher than that of the module's pom.xml).

But what if the parent is not yet installed and if the directory structure is

  1. .
  2. |-- my-module
  3. | `-- pom.xml
  4. `-- parent
  5. `-- pom.xml
The Solution

To address this directory structure (or any other directory structure), we would have to add the <relativePath> element to our parent section.

  1. <project>
  2. <parent>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. <relativePath>../parent/pom.xml</relativePath>
  7. </parent>
  8. <modelVersion>4.0.0</modelVersion>
  9. <artifactId>my-module</artifactId>
  10. </project>

As the name suggests, it's the relative path from the module's pom.xml to the parent's pom.xml.

Project Aggregation

Project Aggregation is similar to Project Inheritance. But instead of specifying the parent POM from the module, it specifies the modules from the parent POM. By doing so, the parent project now knows its modules, and if a Maven command is invoked against the parent project, that Maven command will then be executed to the parent's modules as well. To do Project Aggregation, you must do the following:

  • Change the parent POMs packaging to the value "pom" .
  • Specify in the parent POM the directories of its modules (children POMs)

[top]

Example 3

The Scenario

Given the previous original artifact POMs, and directory structure,

com.mycompany.app:my-app:1's POM

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. </project>

com.mycompany.app:my-module:1's POM

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-module</artifactId>
  5. <version>1</version>
  6. </project>

directory structure

  1. .
  2. |-- my-module
  3. | `-- pom.xml
  4. `-- pom.xml
The Solution

If we are to aggregate my-module into my-app, we would only have to modify my-app.

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. <packaging>pom</packaging>
  7. <modules>
  8. <module>my-module</module>
  9. </modules>
  10. </project>

In the revised com.mycompany.app:my-app:1, the packaging section and the modules sections were added. For the packaging, its value was set to "pom", and for the modules section, we have the element <module>my-module</module>. The value of <module> is the relative path from the com.mycompany.app:my-app:1 to com.mycompany.app:my-module:1's POM (by practice, we use the module's artifactId as the module directory's name).

Now, whenever a Maven command processes com.mycompany.app:my-app:1, that same Maven command would be ran against com.mycompany.app:my-module:1 as well. Furthermore, some commands (goals specifically) handle project aggregation differently.

[top]

Example 4

The Scenario

But what if we change the directory structure to the following:

  1. .
  2. |-- my-module
  3. | `-- pom.xml
  4. `-- parent
  5. `-- pom.xml

How would the parent pom specify its modules?

The Solution

The answer? - the same way as Example 3, by specifying the path to the module.

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. <packaging>pom</packaging>
  7. <modules>
  8. <module>../my-module</module>
  9. </modules>
  10. </project>

Project Inheritance vs Project Aggregation

If you have several Maven projects, and they all have similar configurations, you can refactor your projects by pulling out those similar configurations and making a parent project. Thus, all you have to do is to let your Maven projects inherit that parent project, and those configurations would then be applied to all of them.

And if you have a group of projects that are built or processed together, you can create a parent project and have that parent project declare those projects as its modules. By doing so, you'd only have to build the parent and the rest will follow.

But of course, you can have both Project Inheritance and Project Aggregation. Meaning, you can have your modules specify a parent project, and at the same time, have that parent project specify those Maven projects as its modules. You'd just have to apply all three rules:

  • Specify in every child POM who their parent POM is.
  • Change the parent POMs packaging to the value "pom" .
  • Specify in the parent POM the directories of its modules (children POMs)

[top]

Example 5

The Scenario

Given the previous original artifact POMs again,

com.mycompany.app:my-app:1's POM

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. </project>

com.mycompany.app:my-module:1's POM

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-module</artifactId>
  5. <version>1</version>
  6. </project>

and this directory structure

  1. .
  2. |-- my-module
  3. | `-- pom.xml
  4. `-- parent
  5. `-- pom.xml
The Solution

To do both project inheritance and aggregation, you only have to apply all three rules.

com.mycompany.app:my-app:1's POM

  1. <project>
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. <packaging>pom</packaging>
  7. <modules>
  8. <module>../my-module</module>
  9. </modules>
  10. </project>

com.mycompany.app:my-module:1's POM

  1. <project>
  2. <parent>
  3. <groupId>com.mycompany.app</groupId>
  4. <artifactId>my-app</artifactId>
  5. <version>1</version>
  6. <relativePath>../parent/pom.xml</relativePath>
  7. </parent>
  8. <modelVersion>4.0.0</modelVersion>
  9. <artifactId>my-module</artifactId>
  10. </project>

NOTE: Profile inheritance the same inheritance strategy as used for the POM itself.

[top]

Project Interpolation and Variables

One of the practices that Maven encourages is don't repeat yourself. However, there are circumstances where you will need to use the same value in several different locations. To assist in ensuring the value is only specified once, Maven allows you to use both your own and pre-defined variables in the POM.

For example, to access the project.version variable, you would reference it like so:

  1. <version>${project.version}</version>

One factor to note is that these variables are processed after inheritance as outlined above. This means that if a parent project uses a variable, then its definition in the child, not the parent, will be the one eventually used.

Available Variables

Project Model Variables

Any field of the model that is a single value element can be referenced as a variable. For example, ${project.groupId}${project.version},${project.build.sourceDirectory} and so on. Refer to the POM reference to see a full list of properties.

These variables are all referenced by the prefix "project.". You may also see references with pom. as the prefix, or the prefix omitted entirely - these forms are now deprecated and should not be used.

Special Variables
project.basedir The directory that the current project resides in.
project.baseUri The directory that the current project resides in, represented as an URI. Since Maven 2.1.0
maven.build.timestamp The timestamp that denotes the start of the build. Since Maven 2.1.0-M1

The format of the build timestamp can be customized by declaring the property maven.build.timestamp.format as shown in the example below:

  1. <project>
  2. ...
  3. <properties>
  4. <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
  5. </properties>
  6. ...
  7. </project>

The format pattern has to comply with the rules given in the API documentation for SimpleDateFormat. If the property is not present, the format defaults to the value already given in the example.

Properties

You are also able to reference any properties defined in the project as a variable. Consider the following example:

  1. <project>
  2. ...
  3. <properties>
  4. <mavenVersion>2.1</mavenVersion>
  5. </properties>
  6. <dependencies>
  7. <dependency>
  8. <groupId>org.apache.maven</groupId>
  9. <artifactId>maven-artifact</artifactId>
  10. <version>${mavenVersion}</version>
  11. </dependency>
  12. <dependency>
  13. <groupId>org.apache.maven</groupId>
  14. <artifactId>maven-project</artifactId>
  15. <version>${mavenVersion}</version>
  16. </dependency>
  17. </dependencies>
  18. ...
  19. </project>

Introduction to the POM的更多相关文章

  1. maven权威指南学习笔记(五)—— POM

    1. 简介 Archetype插件通过 pom.xml 文件创建了一个项目.这就是项目对象模型 (POM),一个项目的声明性描述. 当Maven运行一个目标的时候,每个目标都会访问定 义在项目POM里 ...

  2. maven POM —— maven权威指南学习笔记(五)

    1. 简介 Archetype插件通过 pom.xml 文件创建了一个项目.这就是项目对象模型 (POM),一个项目的声明性描述. 当Maven运行一个目标的时候,每个目标都会访问定 义在项目POM里 ...

  3. Maven POM文件介绍

    1. POM文件是什么 1.1 Super POM 1.2 Minimal POM 1.3 Effective POM 3. 项目继承 和 项目聚合 2.1 Project Inheritance 项 ...

  4. Maven 核心原理

    Maven 核心原理 标签 : Java基础 Maven 是每一位Java工程师每天都会接触的工具, 但据我所知其实很多人对Maven理解的并不深, 只把它当做一个依赖管理工具(下载依赖.打包), M ...

  5. maven官方教程

    What is Maven? At first glance Maven can appear to be many things, but in a nutshell Maven is an att ...

  6. maven command to create your application

    How do I make my first Maven project? We are going to jump headlong into creating your first Maven p ...

  7. Maven学习笔记1

    Maven是什么? 百度百科:Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具. 这些描述总是让人更加难理解Maven,扔掉它,咱们先看看Mave ...

  8. Maven入门指南

    Maven入门指南 本指南旨在第一次为使用Maven的人员提供参考,但也打算作为一本包含公共用例的独立参考和解决方案的工具书.对于新用户,建议您按顺序浏览该材料.对于更熟悉Maven的用户,本指南致力 ...

  9. Introduction to the Build Lifecycle

    Introduction to the Build Lifecycle Table Of Contents Build Lifecycle Basics Setting Up Your Project ...

随机推荐

  1. windows下配置lamp环境(5)---配置MySQL5.6

    开始配置mysql 1.创建配置文件my.ini   1.进入C:\wamp\MySQL   2.把my-default.ini 另存一份:my.ini   3.开始编辑mysql的配置文件,打开my ...

  2. 当开始输入文字以及完成文字输入时,变换text field的背景以及系统自带一键删除的 叉叉

    当开始输入文字以及完成文字输入时,变换text field的背景. -(BOOL) textFieldShouldBeginEditing:(UITextField *)textField{ [tex ...

  3. CentOS7配置Nodejs环境安装记录

    今天购买了阿里云服务器,系统选的是CentOS7,下面记录下在它上面安装Nodejs环境的过程,本次操作是直接连接的阿里云服务器的管理终端. 1.由于是纯净的环境,先通过以下命令安装nodejs编译及 ...

  4. 另一种root方法,Android boot.img破解

    一.破解原理 Android手机获得Root权限,其实就是让/system和/data分区获得读写的权限.这两个分区的权限配置,一般在根分区的init.rc文件中,修改这个文件可永久获得root权限. ...

  5. Android窗口管理服务WindowManagerService计算Activity窗口大小的过程分析

    来自http://blog.csdn.net/luoshengyang/article/details/8479101 在Android系统中,Activity窗口的大小是由WindowManager ...

  6. LeetCode_sqrt(x)

    class Solution { public: int sqrt(int x) { // Start typing your C/C++ solution below // DO NOT write ...

  7. SeekBar.OnSeekBarChangeListener解析

    public static interface SeekBar.OnSeekBarChangeListener android.widget.SeekBar.OnSeekBarChangeListen ...

  8. vim 中Ctags的安装和使用

    Ctags是一个用来为源文件中的标识符(如变量.函数.类成员.宏定义等)创建索引文件的程序.这些tags文件能被编辑器或其它工具用来快速查找定位源代码中的符号(tag/symbol),如变量名,函数名 ...

  9. java开发经验分享(一)

    一. 编码 1. 约束自己,规范编码习惯 充足的代码注释.标准缩进的格式.注意命名规范.参考<开发管理规范> "看上去"专业能促进代码质量.越是难看的代码,在它的演化过 ...

  10. 批量更新sql |批量update sql

    图所示现需要批量更新table2表内字段Pwd更新userName对IP地址username与Ip对应关系table1所示 update table2 set pwd=table1.ip from t ...