Overcoming lack of SocketUtils in Spring Boot 3 - spring

I'm preparing to the migration of a Spring Boot service to Spring Boot 3 (I'm trying version 3.0.0-RC1) and unfortunately I'm facing the lack of SocketUtils that has been removed.
This means that some libraries that I'm using for testing (e.g. WireMock) don't work. I'm following Introduce TestSocketUtils as a replacement for SocketUtils #28210 hoping it will resume some tests that currently fail to load.
Do you know some workarounds or other tools I can use in the meanwhile to test the service at the API layer?

I was hitting the same issue causing this exception:
java.lang.NoClassDefFoundError: org/springframework/util/SocketUtils
The fix for me was to upgrade the spring-cloud-contract-wiremock dependency to 4.0.0-M5.
I also had to add this into my pom as the version wasn't available otherwise:
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
I didn't try any earlier versions to see where the fix was introduced, but you can find them here:
https://repo.spring.io/ui/native/milestone/org/springframework/cloud/spring-cloud-contract-wiremock/

Related

Why maven is not able to download "SNAPSHOT" artifacts from azure artifacts repository? (Snapshot translation to timestamp is malfunctioning)

Maven is not able to download artifact when referred by version such as 'XXX-SNAPSHOT' but it is able to download every other dependency from it. It even download the SNAPSHOT if & only if I replace 'SNAPSHOT' by the real timestamp, for example, replace 155-SNAPSHOT by 155-20220224.175558-1.
We are hosting SNAPSHOTS and releases both under the same azur artifact feed. Any advice on how to approach/fix this missing snapshot translation to timestamp?
I wasn't able find the detailed documentation on how this snapshot translation mechanism works on client or server side, can anyone please point it to me?
<dependency>
<groupId>com.st.services.clients</groupId>
<artifactId>st-ccs-web-service</artifactId>
<!-- <version>155-SNAPSHOT</version> --><!-- not works -->
<version>155-20220224.175558-1</version>
</dependency>
<repositories>
<repository>
<name>My Hosted Maven Repo Group</name>
<id>maven-feed</id>
<url>https://pkgs.dev.azure.com/my-org/my-project/_packaging/maven-feed/maven/v1
</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
Not the outcome you were after, but,
Having also tried this myself, I think Azure DevOps simply does not support this.
There are a few aspects of Azure DevOps's Artifacts feature that doesn't entirely align with Maven/how Maven does things. Unfortunately, this appears to be one of them.
(An example of another is the management of timestamped snapshots of the same version as individual versions, which Sonatype Nexus can do but DevOps Artifacts cannot).

Unable to request maven dependencies through ant

Working on Ubuntu 18.04 on an ANT project. It seems that maven recently required people to make https requests instead of http requests, but I am unsure how to change this configuration. A friend on OSX has not run into this issue. following the links in the error message takes me to this page.
https://support.sonatype.com/hc/en-us/articles/360041287334
You can update the repository links on your pom.xml file. It looks like this
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
Change the URLs to https to resolve the issue.

OSE v3 connection timeout to maven repo while building maven project

we are getting connection timeout error while building maven project.some can please help us on this issue.same project is working on osev2.
When you had this kind of problems, check out which repositories contains the requested artifact. In this case as you can see in the link below, 3 repositories contains it. Add one of to your repositories/pluginRepositories section of your pom.xml.
Since this is a plugin you should add it as plugin repository.
<pluginRepositories>
....
<pluginRepository>
<id>central</id>
<name>maven central</name>
<url>http://central.maven.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
Also 2.5 is a fairly old version, there is a newer 3.0.2 version (I would recommend changing it to this).
https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-resources-plugin/2.5

Multiple repositories in Maven with the same package

Assuming I have this in my settings.xml file:
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>one</id>
<name>release</name>
<url>http://localhost:8081/artifactory/A</url>
</repository>
<repository>
<snapshots />
<id>two</id>
<name>snapshot</name>
<url>http://localhost:8081/artifactory/B</url>
</repository>
Both URLs contain a package called org.apache.something but different versions. How do I force maven to choose from A and notB.
Since repository A is handling release versions and B is handling snapshots I'm expecting no conflict between them.
Simply declaring your dependency version should guide the choice between them.
Remember however that repository are searched in the order you declare them, so the first one owning the version you declare will win.
But again I expect no differences on same artifact+stable_version among different repositories.

Qi4j maven configuration

I'm currently trying to figure out how Qi4j works. So i decided to start with a simple example. I tried to use the Qi4j lib in my pom.xml and am now facing the problem, that the artifact can't be found. I'm using NetBeans 7.0.1 and my pom.xml parts are shown below:
<repository>
<id>qi4j-official</id>
<url>http://repository.ops4j.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<dependency>
<groupId>org</groupId>
<artifactId>org.qi4j</artifactId>
<version>1.4</version>
</dependency>
I'm i doing something wrong? Thanks a lot.
Qi4j consists of many many artifacts, to keep the total footprint down as most applications won't use all bits and pieces.
<groupId>org.qi4j.core</groupId>
contains the artifacts (as of 1.3)
<artifactId>org.qi4j.core.api</artifactId>
<artifactId>org.qi4j.core.spi</artifactId>
<artifactId>org.qi4j.core.runtime</artifactId>
<artifactId>org.qi4j.core.bootstrap</artifactId>
<artifactId>org.qi4j.core.testsupport</artifactId>
For "compile" scope api and bootstrap should be enough. testsupport is obviously "test" scope and runtime should not be used by your code and only be a "runtime" dependency.
<groupId>org.qi4j.library</groupId>
The Libraries varies greatly in completeness and quality. Extensions can depend on libraries but not the other way around.
<groupId>org.qi4j.extension</groupId>
Extensions implements the slowly growing SPI pluggable functionalities; entity stores, indexing/query and caching. Next release (2.0) will have more extensions for value serialization and others.
Hope that helps, or meet the Qi4j community at the qi4j-dev Google Group for additional support.
Based what i can see in the given repository the groupId and artifactId are completely different...
http://repository.ops4j.org/maven2/org/qi4j/core/org.qi4j.core.spi/1.4/org.qi4j.core.spi-1.4.pom
To learn how to depend on Qi4j in your build see the dedicated how-to that's now present on the Qi4j website: http://qi4j.org/latest/howto-depend-on-qi4j.html
Here are the release and snapshot repositories :
https://repository-qi4j.forge.cloudbees.com/release/
https://repository-qi4j.forge.cloudbees.com/snapshot/
Weekly SNAPSHOTs are uploaded the snapshot repository so you need to add this url as a maven repository :
<repositories>
[...]
<repository>
<id>qi4j-snapshots</id>
<url>https://repository-qi4j.forge.cloudbees.com/snapshot/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
[...]
</repositories>
And then you can add dependencies to Qi4j:
<dependencies>
[...]
<dependency>
<groupId>org.qi4j.core</groupId>
<artifactId>org.qi4j.core.bootstrap</artifactId>
<version>QI4J_VERSION</version>
</dependency>
<dependency>
<groupId>org.qi4j.core</groupId>
<artifactId>org.qi4j.core.runtime</artifactId>
<version>QI4J_VERSION</version>
</dependency>
[...]
</dependencies>
Where QI4J_VERSION is the version you want to use.

Resources