Spring Cloud Config Server - 1.4.2.RELEASE
Java 8
I have a vanilla Spring Cloud Config Server (POM below).
Main features used are:
downloading config files from Git
encryption/decryption through an SSH file
When I start it up with no memory constraints it cranks up to 7460.88 Mb.
When I add constraints like below, it is at 3653.82 Mb.
-Xms256m -Xmx256m -Xmn96m -XX:+UseNUMA -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled
As you can tell by my memory constraints I was expecting it to hang out around 256 Mb.
Was this an unrealistic expectation?
Is there a way to get it down further?
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>any.group</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-cloud-config-server</name>
<description>Spring-Cloud-Config-Server that loads configuration from GIT for Spring Boot Applications.</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>1.4.2.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>${spring-cloud.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Nevermind, believe I was calculating the memory wrong.
I was using this command originally: https://stackoverflow.com/a/44711589/4681044
But instead now I used the "top" command and got the percentage and used that against the total available and got 492Mb.
Related
I am using maven and tomcat7 to develop web project,but I found a weird problem:the redeployed project lost some files compared with the war file,thus I can not run the project after it redeployed.
Let me say it step by step:
This is the project structure of my maven project:
This is my configuration code of the pom.xml file:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lucumt</groupId>
<artifactId>vm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>vm</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<finalName>vm</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8085/manager/text</url>
<server>tm7</server>
<path>/vm</path>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
when I run tomcat7:deploy in eclipse using m2eclipse when tomcat7 is running,the project is packaged as vm.war and it will deployed in webapps folder for tomcat7,the file in vm folder will look like this,and I can run my project now:
But when I run tomcat7:redeploy,the file in the vm folder will look like below,the jsp and velocity file is missing and thus I can not run this project using tomcat again!
However,when I checked the vm.war file using WinRA,I found everything is okay,the jsp and velocity files are inside as below:
I think the files are missing when tomcat make the vm.war file in to vm,but I do not know why it happend,and I do not know how to solve it,can anyone help me? Is there is wrong configuration in my pom.xml file?
Thanks in advance!
I am new to Maven and starting moving my project to maven. I have created the following POM.
when i issue install command, it gives me FATAL ERROR.
I am using maven 2.2.1 version and JDK 1.5.
My POM is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<prerequisites>
<maven>2.2.1</maven>
</prerequisites>
<groupId>my.project.group</groupId>
<artifactId>my.artifact</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6.SEC01</version>
</dependency>
</dependencies>
</project>
Thanks for any help.
You are missing a mandatory tag from your project address structure groupId:artifactId:version
Put the following tag after ... with some version info (i.e. 1.x.x) and try.
<version>1.0.0</version>
Reference : http://maven.apache.org/pom.html
I am trying to rename my artifacts in the repository folder of my eclipse-repository module. At the moment they are auto generated like ...1.0.0.v20130315-1927.jar.
I haven't found any configuration parameter that works. I have tried to use the qualifier setting in the configuration (see tycho-p2-repository-plugin), but it doesn't work.
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>development.statTool</groupId>
<artifactId>Application</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>development.statTool</groupId>
<artifactId>development.statTool.p2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
<properties>
<tycho-version>0.16.0</tycho-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-repository-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<qualifier>abcd</qualifier>
</configuration>
</plugin>
</plugins>
</build>
</project>
My solution is to use the tycho-packaging-plugin. Only "disadvantage" changing the build qualifier needs to rebuild all modules contained by the repository.
Here the part out of my parent pom.xml:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho.version}</version>
<dependencies>
<dependency>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-buildtimestamp-jgit</artifactId>
<version>${tycho-extras.version}</version>
</dependency>
</dependencies>
<configuration>
<strictBinIncludes>false</strictBinIncludes>
<format>'rev${rev}-'yyyyMMdd-HHmm</format>
</configuration>
</plugin>
try this:
mvn -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=13.3.0.1-SNAPSHOT
or simply search text "1.0.0-SNAPSHOT" and replace it with "13.3.0.1" using Actual Search and Replace tool.
I have a developed application and I am just trying to make the build process easy. The POM file for parent looks like this:
<parent>
<groupId>com.shc.obu.ca</groupId>
<artifactId>shcobuca-pom</artifactId>
<version>1.1.0</version> </parent>
<groupId>com.shc.obu.ca.osol</groupId> <artifactId>apps-pom</artifactId> <version>${currVersion}</version> <packaging>pom</packaging> <name>Outlet Apps</name>
<scm>
<connection>scm:svn:https://ushofsvpsvn2.intra.searshc.com/svn/outlet/outlet/trunk/apps</connection>
<developerConnection>scm:svn:https://ushofsvpsvn2.intra.searshc.com/svn/outlet/outlet/trunk/apps</developerConnection> </scm>
<profiles>
<profile> <id>www</id>
<activation> <activeByDefault>true</activeByDefault> </activation>
<modules>
<module>www</module>
<module>modules</module>
</modules>
</profile>
<profile>
<id>mts</id>
<activation> <activeByDefault>true</activeByDefault> </activation>
<modules>
<module>mts</module>
<module>modules</module>
</modules>
</profile>
<profile> <id>search</id>
<activation> <activeByDefault>true</activeByDefault> </activation>
<modules>
<module>modules</module>
<module>search</module>
</modules>
</profile> </profiles>
<repositories>
<repository>
<id>obu.ca.repo.release</id>
<snapshots><enabled>false</enabled></snapshots>
<url>http://maven.cal.intra.sears.com/release</url>
</repository>
<repository>
<id>obu.ca.repo.snapshot</id>
<releases><enabled>false</enabled></releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>interval:5</updatePolicy>
</snapshots>
<url>http://maven.cal.intra.sears.com/snapshot</url>
</repository> </repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<env>trunk</env>
<currVersion>1.2.0</currVersion> </properties> </project>
This file shows that it has three profiles which are basically independent child project. I am adding the cargo plugin to this file as below:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<home>
C:\tools\apache-tomcat-6.0.26
</home>
</container>
<configuration>
<properties>
<cargo.servlet.port>
8082
</cargo.servlet.port>
<cargo.jvmargs>
"-Xdebug" "-Xrunjdwp:transport=dt_socket,address=4646,server=y,suspend=n"
</cargo.jvmargs>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
But when I run 'mvn cargo:start', tomcat instance runs fine but none of the child apps get deployed. Is there a way that I can make my first child application (www) (which generates a war file called www-webapp-1.2.0.war) auto deployed?
Update: Thanks Pascal. I tried modifying the build tag as below:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<home>
C:\tools\apache-tomcat-6.0.26
</home>
</container>
<configuration>
<properties>
<cargo.servlet.port>
8082
</cargo.servlet.port>
<cargo.jvmargs>
"-Xdebug" "-Xrunjdwp:transport=dt_socket,address=4646,server=y,suspend=n"
</cargo.jvmargs>
</properties>
<deployables>
<deployable>
<groupId>com.shc.obu.ca.osol</groupId>
<artifactId>www-webapp-1.2.0</artifactId>
<type>war</type>
<properties>
<context>acontext</context>
</properties>
</deployable>
</deployables>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
But still it's not working. It's giving build error as below:
Artifact [com.shc.obu.ca.osol:www-webapp-1.2.0:war] is not a dependency of the project.
I tried 'www-webapp' and 'www' as artifact id as well but the error remained the same.
And when I add the same to dependency tags, it gives some kind of cyclic reference error as below:
'The projects in the reactor contain a cyclic reference'
You need to list your www module as a module to deploy inside a <deployable> element. From the Maven2 Plugin Reference Guide:
If no deployable is specified and the project's packaging is war, ear or ejb and there is no deployer specified then the generated artifact is added automatically to the list of deployables to deploy
Since your project has a packaing of type pom, it is not candidate for deployment and nothing gets deployed.
Here is an example:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<home>C:\tools\apache-tomcat-6.0.26</home>
</container>
<configuration>
<properties>
<cargo.servlet.port>8082</cargo.servlet.port>
<cargo.jvmargs>
"-Xdebug" "-Xrunjdwp:transport=dt_socket,address=4646,server=y,suspend=n"
</cargo.jvmargs>
</properties>
<deployables>
<!-- application to deploy -->
<deployable>
<groupId>com.acme</groupId>
<artifactId>mywebapp</artifactId>
<type>war</type>
<properties>
<context>acontext</context>
</properties>
</deployable>
</deployables>
</configuration>
</configuration>
</plugin>
Update:
(...) It's giving build error as below
Artifact [com.shc.obu.ca.osol:www-webapp-1.2.0:war] is not a dependency of the project. I tried 'www-webapp' and 'www' as artifact id as well but the error remained the same.
I forgot about that but it looks like Cargo expect a deployable to be a dependency of the project where Cargo is started.
And when I add the same to dependency tags, it gives some kind of cyclic reference error as below: 'The projects in the reactor contain a cyclic reference'
Which is normal. An artifact can't be a sub-module and a dependency of a given project or you get a cyclic dependency (you need a dependency to build a module which is the dependency, chicken and egg problem).
My suggestion would be to move the cargo configuration to the www module or to create a dedicated module for your functional tests (this is usually what I do) and to declare www as dependency of this module.
Here is a sample of how to do multi-module deployments with Cargo. It has a parent and three modules, where one of them does the deployment of all three with cargo. You can run mvn cargo:run from the third module to get all of them deployed.
==================== PARENT 1 =========================
<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>com.blah.test</groupId>
<artifactId>blah-service</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>blah-service-module1</module>
<module>blah-service-module2</module>
<module>blah-service-module3</module>
</modules>
</project>
==================== MODULE 1 =========================
<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>
<parent>
<groupId>com.blah.test</groupId>
<artifactId>blah-service</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>blah-service-module1</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
</project>
==================== MODULE 2 =========================
<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>
<parent>
<groupId>com.blah.test</groupId>
<artifactId>blah-service</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>blah-service-module2</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
</project>
========== MODULE 3: the one which deploys all three with cargo =========================
<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>
<parent>
<groupId>com.blah.test</groupId>
<artifactId>blah-service</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>blah-service-module3</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.blah.test</groupId>
<artifactId>blah-service-module1</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.blah.test</groupId>
<artifactId>blah-service-module2</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.6</version>
<configuration>
<container>
<containerId>jetty6x</containerId>
<type>embedded</type>
</container>
<deployables>
<deployable>
<groupId>com.blah.test</groupId>
<artifactId>blah-service-module1</artifactId>
<type>war</type>
<properties>
<context>api/blah/module1</context>
</properties>
</deployable>
<deployable>
<groupId>com.blah.test</groupId>
<artifactId>blah-service-module2</artifactId>
<type>war</type>
<properties>
<context>api/blah/module2</context>
</properties>
</deployable>
<deployable>
<groupId>com.blah.test</groupId>
<artifactId>blah-service-module3</artifactId>
<type>war</type>
<properties>
<context>api/blah/module3</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
</build>
</project>
I'm trying to build a jar that has an xml file as a resource. I'd like to apply a filter to that xml to insert the name of a dependency into the xml. The filtering is working, because I was able to drop in ${project.build.finalName} and get it replaced. I found one hint that the property I'm looking for might be
${project.dependencies[0].artifactId}
but that doesn't seem to work. I'm looking to replace
<fileName>${project.dependencies[0].artifactId}</fileName>
with
<fileName>OtherLibrary</fileName>
Is that possible?
xml, which is in src/main/resources:
<somenode>
<fileName>${project.dependencies[0].artifactId}</fileName>
</somenode>
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.foo</groupId>
<artifactId>Thing</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Thing</name>
<url>http://maven.apache.org</url>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.pts</groupId>
<artifactId>OtherLibrary</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Damn, you're right, this property doesn't get replaced during the filtering of resources. That's weird and it sounds like a bug in the Maven Resources Plugin because this property is correctly interpolated during the process-resources phase as I'll demonstrate in the workaround I'm suggesting below (based on the maven-antrun-plugin and the replace task).
First, add the following to your POM:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<echo>${project.dependencies[0].artifactId}</echo><!-- I'm a test -->
<replace file="${project.build.outputDirectory}/myxmlfile.xml"
token="###" value="${project.dependencies[0].artifactId}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Then, update your XML file into:
<somenode>
<fileName>###</fileName>
</somenode>
With these changes, running mvn process-resources would produce the following result:
$ cat target/classes/myxmlfile.xml
<somenode>
<fileName>OtherLibrary</fileName>
</somenode>
Which proves the property is interpolated (but not set during maven filtering of resources)1. And if you need to filter more than one file, the replace task can take a fileset. Adapt it to suit your needs.
1 Actually, it would be nice to create a new Jira for this bug in the Maven 2.x Resources Plugin. I've created MRESOURCES-118.
The indexed properties will only be available inside plugin configuration due to the way Maven interpolates the POM - so it is available to antrun's replace task, but not the filtering.
However, accessing dependencies by index is not very robust - it is susceptible to changes in the parent. You might instead use the following in pom.xml:
<properties>
<fileName>some-name</fileName>
</properties>
...
<dependency>
<groupId>your.group.id</groupId>
<artifactId>${fileName}</artifactId>
...
</dependency>
You can then continue to filter using the property name:
<somenode>
<fileName>${fileName}</fileName>
</somenode>