How can I increase the number of http(s) connections a maven build will use to download and upload Artifacts from the repository (Artifactory or similar).
I have seen this page:
https://maven.apache.org/guides/mini/guide-http-settings.html
But it does not say what is the parameter and syntax to set it.
I am using Apache Maven 3.6.0
according to Maven documentation By default, Maven 2.1.0+ will download up to 5 artifacts (from different groups) at once. To change the size of the thread pool, start Maven using following switch option to change default value:
-Dmaven.artifact.threads
for example :
mvn -Dmaven.artifact.threads=1 verify
You may wish to set this option permanently, in which case you can use the MAVEN_OPTS environment variable. For example:
export MAVEN_OPTS=-Dmaven.artifact.threads=3
There is options for maven:
maven.artifact.threads for configuring parallel artifacst resolution
You can use it as is described on site:
https://maven.apache.org/guides/mini/guide-configuring-maven.html
You can also add this properties to your settings.xml so will be affected for all builds:
<settings>
<profiles>
<profile>
<id>props</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.artifact.threads>10</maven.artifact.threads>
</properties>
</profile>
</profiles>
</settings>
Related
when i'm navigating to a maven dependency class, i get a .class file with this comment on top and no doc is shown :
// Failed to get sources. Instead, stub sources have been generated by the disassembler.
// Implementation of methods is unavailable.
I don't have the issue with Java classes, only maven dependencies.
I have enabled download sources in the maven settings.xml and in the java extension pack settings.
Anyone has any idea how to solve this please ?
i had the same problem and i solve it,try this:
set settings.json in vscode,
"java.eclipse.downloadSources": true,"java.maven.downloadSources": true
add follow settings in settings.xml of maven:
<settings>
<!-- ... other settings omitted ... -->
<profiles>
<profile>
<id>downloadSources</id>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>downloadSources</activeProfile>
</activeProfiles>
</settings>
3.reopen vscode and it will download javadoc
Could you try to set the "java.jdt.ls.java.home" manually? Set it to the JDK you installed on your computer.
Some people others had run across this kind of problem. It looks like an issue with the language server's embedded JRE.
I had this issue previously, and I couldn't change the language server's embedded JRE due the version being <17. The fix was adding the following line into settings.json.
"maven.terminal.useJavaHome": true
I would like to know if using IntelliJ, is possible to run all test in the visual environment choosing a specific Junit category.
At the moment if you execute:
mvn clean test
you execute Fast Tests, but how to use IntelliJ to choose Slow or Fast?
Fragment of pom.xml
<profiles>
<profile>
<id>SlowTest</id>
<properties>
<testcase.groups>YOUR.PROJECT.test.categories.Slow</testcase.groups>
</properties>
</profile>
<profile>
<id>FastTest</id>
<properties>
<testcase.groups>YOUR.PROJECT.test.categories.Fast</testcase.groups>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
Many thanks in Advance
Juan Antonio
Your profiles are focusing the test run on specific categories. The JUnit Run/Debug configuration in IntelliJ also allows you to focus a JUnit run on a specific category.
You can access this configuration window from Run > Edit Configurations
Here's a screenshot showing a saved confoguiraiton named SlowTests which runs all tests having the category: com.stackoverflow.surefire.SlowTests:
You can save any such configuration by clicking on the file icon in the top left hand corner of this window and then that configuration will be available in the Run menu and you can even associate a keyboard short cut with it.
More information in the docs.
If you created your project using the pom.xml, in the "Maven Projects"-View you can activate the profiles you want to be active. There (Lifecycle) you can start the goal you want to be executed for each module as well.
How to get this: View->Tool Windows->Maven Projects
I am running the spring boot app by passing the spring active profile like below:
spring-boot:run -Dspring.profiles.active=dev
But how do I pass the spring.profiles.active when creating the package using maven. Following is the maven command:
mvn clean install
In case someone have the same situation, you can achieve this with 2 steps with spring boot and maven:
First in spring properties or yaml file, add the spring.profiles.active with it's value as placeholder:
spring.profiles.active=#active.profile#
Second, pass the value with maven:
mvn clean install -Dactive.profile=dev
When the jar/war packaged, the value will be set to dev.
you can also leverage the use of maven profiles:
<profiles>
<profile>
<id>dev</id>
<properties>
<active.profile>dev</active.profile>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<active.profile>test</active.profile>
</properties>
</profile>
</profiles>
Then run:
mvn clean install -Pdev
Maven is a build-time tool, the only way to make it modify the eventual runtime behaviour of the built artifact is to use its (build-time) profiles. This must not be confused with Spring's runtime profiles which are parameters instructing the Spring container to bootstrap application in a specific way.
In other words, the spring.profiles.active parameter doesn't get "baked into" the war file by maven, you'll still need to pass it when starting the application up, be it via command-line parameters or configuration file or whatever mechanism your servlet container offers.
For package, you may replace install with package
mvn clean install -P dev
You can use environment variables.
export SPRING_PROFILES_ACTIVE=some,test,profiles
mvn spring-boot:run
I have created one maven project(Desktop application). Now I would like to make the same project, but I want to change some of the dependency versions.
For example I have lib-1.0.jar and lib-2.0.jar. Now I would like to debug one of my projects with lib-1.0.jar and another project with lib-2.0.jar.
What is the best approach to achieve this? I dont want to edit my pom by hand everytime I debug the project.
Set a property for the version number, something like:
<properties>
<lib.version>1.0</lib.version>
</properties>
And use that in the dependency:
<dependency>
<groupId>lib.group</groupId>
<artifactId>lib</artifactId>
<version>${lib.version}</version>
</dependency>
Now you can simply override this in a profile:
<profile>
<id>bleeding-edge</id>
<properties>
<lib.version>2.0</lib.version>
</properties>
</profile>
And run with the profile to use the different version:
mvn -P bleeding-edge clean install
Note that this will probably confuse your IDE no end - with some IDE's you can set the profiles used.
I installed Sonar Plugin on my eclipse, (i ran the server .../StartSonar.bat) and when I do test connection on LocalHost:9000 its okay (Connection Sucessfull). Now What should I do to associate my projects with sonar? I'm kind lost. I'm rookie.
If your projects are built with maven then all you need to do is run mvn sonar:sonar on your project root folder (where your pom.xml is located) and the report will get pushed to your sonar instance.
And also you need to have the sonar profile set up in your settings.xml. Example below:
<settings>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- EXAMPLE FOR MYSQL -->
<sonar.jdbc.url>
jdbc:mysql://localhost:9000/sonar?useUnicode=true&characterEncoding=utf8
</sonar.jdbc.url>
<sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<!-- SERVER ON A REMOTE HOST -->
<sonar.host.url>http://localhost:9000</sonar.host.url>
</properties>
</profile>
</profile>
Read more here.
To use the plugin in Eclipse SonarQube you must have a sonarQube instance (server) installed, documentation on how to do can be found at the following link http://docs.sonarqube.org/display/SONAR/Setup+and+Upgrade.
Once you have performed an initial analysis of your code, either as maven says Tomasz or sonar-runner, (http://docs.sonarqube.org/display/SONAR/Analyzing+Source+Code) you can, with sonarqube plugin for Eclipse, set a reference to the server in the General preferences Eclipse Window -> Preferences -> SonarQube -> Servers and project level should "link" or refer to said first analysis located in your server.
Once you do this, every time you make an analysis of your code with SonarQube from Eclipse, it will connect to the server, the existing evidences will be brought and will do an incremental analysis of your code with respect to information collected on the remote analysis.