Please tell me what i do wrong.
I download maven project from springboot.io and import to IDE(intelliJ).
Start to deploy I get error
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy
> (default-deploy) on project securing-web-initial: Deployment failed:
> repository element was not specified in the POM inside
> distributionManagement element or in
> -DaltDeploymentRepository=id::layout::url parameter -> [Help 1] [ERROR]
I read like this Problem with deploying spring boot application and add to POM.xml
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Internal repo</name>
<url>E:\!Distrib\repo</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>example-repo</id>
<name>Example Repository</name>
<url>
E:\!Distrib\repo
</url>
</repository>
</repositories>
Nothing changed.
If I use a URL C:\!Users\tgdavies\testrepo I get the error message: Failed to deploy artifacts/metadata: Cannot access C:\!Users\tgdavies\testrepo with type default using the available connector factories: BasicRepositoryConnectorFactory
If I use file:C:\Users\tgdavies\testrepo deploy succeeds.
But your issue is that you do not need to run mvn deploy. Read the tutorial you linked to -- it does not suggest running mvn deploy. To test your code
If you use Maven, you can run the application by using ./mvnw spring-boot:run. Alternatively, you can build the JAR file with ./mvnw clean package and then run the JAR file, as follows:
java -jar target/gs-rest-service-0.1.0.jar
Import I made correctly. It is very easy. I suggested it need a lot of task after import maven project because Run button was not active. As additional automatically was open maven window with deploy and install items)).
intelliJ did not make configuration for run. As a result run button was not active.
Related
I installed the Nexus repository in my notebook, then upload a snapshot project in it. This is how it looks:
Now, I'm trying to build a Docker image, with another project that has the previous project as a dependency. This is my Dockerfile:
FROM maven:3.5.2-jdk-8-alpine AS MAVEN_BUILD
COPY settings.xml /usr/share/maven/ref/
COPY pom.xml /build/
RUN echo $(route -n | awk '/UG[ \t]/{print $2}')
RUN sed -i "s/localhost/$(route -n | awk '/UG[ \t]/{print $2}')/g" /build/pom.xml
COPY src /build/src/
WORKDIR /build/
RUN mvn package -DskipTests=true
# Other stuff that doesn't matter...
I've added this lines to pom.xml to resolve dependencies from Nexus (locahost is replaced (see Dockerfile) with docker gateway IP):
<repositories>
<repository>
<id>maven-group</id>
<url>http://localhost:8081/repository/maven-group/</url>
</repository>
</repositories>
It works as expected until maven needs to dowload my own library dependecy, the one uploaded to Nexus, failing with the message:
[ERROR] Failed to execute goal on project springboot-servicio-producto: Could not resolve dependencies for project com.abarazal.springboot.app.producto:springboot-servicio-producto:jar:0.0.1-SNAPSHOT: Could not find artifact com.abarazal.springboot.app.commons:springboot-servicio-commons:jar:0.0.1-SNAPSHOT in maven-group (http://172.17.0.1:8081/repository/maven-group/) -> [Help 1]
In pom.xml the dependency is declared as:
<dependency>
<groupId>com.abarazal.springboot.app.commons</groupId>
<artifactId>springboot-servicio-commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
What am I missing to make it work?
Check if you have more than 10% free disk space.
This may be an issue caused by elastic search.
I am struggling with the (seemingly) simple task of deploying a maven project to github packages using a github actions workflow. First of all, here's the error I am getting in the maven deploy phase:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project [project name]: Failed to retrieve remote metadata [groupId]:[artifactId]:1.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata [groupId]:[artifactId]:1.0-SNAPSHOT/maven-metadata.xml from/to github (https://maven.pkg.github.com/[username]/[repository]): Failed to transfer file https://maven.pkg.github.com/[username]/[repository]/[groupId as path]/[artifactId]/1.0-SNAPSHOT/maven-metadata.xml with status code 400 -> [Help 1]
(Info: I replaced unneccessary and/or private concrete information with general terms in [brackets])
Most likely, the actual maven-metadata.xml file is not the problem because I have already seen warnings like "could not upload checksum" with status 400 before. I guess that maven-metadata.xml is just the first file it fails on, but probably I am completely wrong with this assumption, please tell me if so.
Probably the most important file is the workflow yaml file:
name: Deploy SNAPSHOT (develop)
on:
push:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up JDK 11
uses: actions/setup-java#v1
with:
java-version: 11
- name: Maven Deploy
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn --settings settings.xml -B -e -Dmaven.wagon.http.pool=false clean deploy
Also quite important: the maven settings.xml file:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github-packages</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github-packages</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub [username] Apache Maven Packages</name>
<url>https://maven.pkg.github.com/[username]</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_USERNAME}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
(Info: same goes for values in brackets as before)
And lastly, the parent pom.xml of my maven project:
<?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>[groupId]</groupId>
<artifactId>[artifactId]</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
[child modules]
</modules>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
</properties>
<dependencies>
[my dependencies]
</dependencies>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub [username] Apache Maven Packages</name>
<url>https://maven.pkg.github.com/[username]/[repository]</url>
</repository>
</distributionManagement>
</project>
Maybe it's also important to say that the GitHub repository belongs entirely to me and therefore I should have all admin rights on it.
Things I've tried:
I have done some research by now and I found that my issue seems to be not uncommon. Although, from all solutions I've found so far, not one has worked.
Official GitHub documentation for setting up workflows
To start of, I used this site as my reference.
This StackOverflow Question
I mostly stuck to all the advice I found in this question and in the answers to it.
This other StackOverflow Question about nexus deploys
The accepted answer of this question provides a checklist. I tried to check that all the bullet points work for me, although I wasn't able to validate everything. I did not find any issue based on this checklist.
This question on the GitHub community forum
The error displayed in this question looks very much like the error I am getting, still the proposed solution did not fix anything for me.
This Answer on a similar GitHub community forum question
This answer suggested using a personal access token instead of the GITHUB_TOKEN. I tried that and it changed nothing.
What I need
Of course I'd be happy if someone can show me what the exact issue of my case is, but it does not need to be that specific. I am trying to set up the most basic pipeline possible and I currently don't want to do more than just deploy a maven snapshot repository to github packages (with github actions). So, if anyone can show me how to do this properly in general, that's also fine. Thanks!
I kinda figured it out myself, but the result is very dissatisfying. The main problem here is:
Note: GitHub Packages does not support SNAPSHOT versions of Apache Maven. Make sure you disable SNAPHOT in your ~/.m2/settings.xml file.
(Source)
So, it seems like GitHub Packages does not support the construct of maven snapshot repositories, which are otherwise very practical. My plan was to set up a workflow that deploys a new SNAPSHOT on the package registry when a push to develop happens. Maven snapshot repositories do not require unique version numbers for deploys, which means I could have built a new version for every push, but the actual dependency version stays fixed. Everyone could then easily try out the latest state of my develop branch, simply by including the fixed snapshot version in their pom files.
Now, how to fix my issue:
Because GitHub packages does not support snapshot repositories, you will have to remove the keyword "SNAPSHOT" from the value in the project.version tag in your pom file. Basically you can put every other version description there, but now it is unique. However if you remove all SNAPSHOT keywords, the workflow should properly deploy a package to the GitHub package registry, at least it worked for me.
If anyone knows a way to "hack" around this SNAPSHOT issue, please tell me. Otherwise this is the only working solution I've found so far.
I have auto-generated java code I want to deploy in our maven repo. The generated code has a pom.xml without the repo info. I what to know if I can deploy the complete maven project in my repo without touching the pom. And by complete maven project, I mean not only the final jar using the file-deploy maven command.
The repo has security enabled and requires usr/pass
I found a way. You need to add the server to the settings file as following:
<servers>
<server>
<id>my-server</id>
<username>user</username>
<password>pass</password>
</server>
</servers>
then I deploy using the following maven command (replacing <url> for the target repo):
mvn deploy -D"altDeploymentRepository=my-server::default::<url>"
i have in settings.xml following config
<profile>
<properties>
<nexus.host>http://localhost:8081/nexus/content/repositories</nexus.host>
</properties>
</profile>
this profile is set as active.
its used in distribution management section of pom
<distributionManagement>
<snapshotRepository>
<id>my-snapshots</id>
<name>my snapshots</name>
<url>${nexus.path}/snapshots</url>
</snapshotRepository>
<repository>
<id>my-releases</id>
<name>my releases</name>
<url>${nexus.path}/releases</url>
</repository>
</distributionManagement>
this works when i run it on local machine, but when the job is executed on jenkins it fails with
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to transfer
com.myapp:sample:pom:1.1.0 from ${nexus.path}/releases was cached in
the local repository, resolution will not be reattempted until the
update interval of my-releases has elapsed or updates are forced.
Original error: Could not transfer artifact com.myapp:sample:pom:1.1.0
from/to my-releases (${nexus.path}/releases): Cannot access
${nexus.path}/releases with type default using the available connector
factories: WagonRepositoryConnectorFactory and 'parent.relativePath'
points at wrong local POM # line 3, column 13
unable to identify the cause of the error
I had the same issue in the past. To resolve this in Jenkins you will need to set the Maven argument so it can find the location of your settings.xml.
You will need to have the settings.xml in the application resources so Jenkins can find it.
To set the argument(In Jenkins, it should be under Goals and options):
-s src/main/resources/settings.xml
However in my instance the Jenkins administrators provided a separate version of maven so the application will have the needed settings.xml and there was no need to provide our own custom settings.xml.
On a side note, you might want to contact the Jenkins Administrators to ensure that they have implemented the proper configurations so Jenkins will be able to deploy the produced artifacts to the repository under the id you have specified.
I'm trying to accessing a server with a maven repo. From my windows machine at work I can access it with my company login. With my mac I can access the server if I connect to it and enter in my windows credentials.
Here is the part of my pom with the rep:
<repositories>
<repository>
<id>repo.id</id>
<url>file:////servername/MavenRepo</url>
<!-- use snapshot version -->
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
here is the part of the settings.xml that I'm using to try to set credentials to access that maven repo. What am I doing wrong?
<server>
<id>repo.id</id>
<username>domain\username</username>
<password>password</password>
</server>
The error is:
[ERROR] Failed to execute goal on project Company-Project: Could not resolve dependencies for project Company-Project:Company-Project:jar:DEVELOP-1.0-SNAPSHOT: Failed to collect dependencies at Company-ProjectName:Company-ProjectName:jar:1.0-SNAPSHOT: Failed to read artifact descriptor for Company-ProjectName:Company-ProjectName:jar:1.0-SNAPSHOT: Could not transfer artifact Company-ProjectName:Company-ProjectName:pom:1.0-SNAPSHOT from/to com.Company.maven (file:////Server.Company.corpnet.local/JenkinsMavenRepo): Repository path /Server.Company.corpnet.local/JenkinsMavenRepo does not exist, and cannot be created. -> [Help 1]
It seems that maven could not find the repository on the file system.
file:////Server.Company.corpnet.local/JenkinsMavenRepo): Repository path /Server.Company.corpnet.local/JenkinsMavenRepo does not exist
Have you mounted the repository file system correctly?
Check if you can access the directory /Server.Company.corpnet.local/JenkinsMavenRepo in the Terminal.
PS
I always would prefer a repository server such as nexus. Is that an option?
Turns out using windows as a filestore for a maven repo is proprietary. I setup a IIS server (http) pointing to that directory which resolves the issue.