Add mysql connector to build maven / nexus in eclipse

I am trying to connect to mysql database in java, so I need to add mysql-connector-java:jareclipse to my project. However, integration with maven does not work.

Here is what I have in my .xml settings:

<profile>
<id>default</id>
<properties>
 <mvn.path>.../maven-3.0.4/bin/mvn.bat</mvn.path>
 <javac.5>...bin/javac.exe</javac.5> 
 <javac.6>..../javac.exe</javac.6>
</properties>
<repositories>
 <repository>
  <id>central-repository</id>
  <name>OSS central Maven Release Repository</name>
  <url>https://oss.sonatype.org/content/repositories/releases</url>
 </repository>
 <repository>
  <id>public-repository-main</id>
  <name>Central Repository</name>
  <url>https://repo1.maven.org/maven2</url>
 </repository>
 <repository>
  <id>public-repository</id>
  <name>OSS Maven Release Repository</name>
  <url>https://oss.sonatype.org/content/groups/public</url>
 </repository>
</repositories>
</profile>

<interactiveMode>true</interactiveMode> 
<!-- offline
 | Determines whether maven should attempt to connect to the network when executing
 | a build.
 | This will have an effect on artifact downloads, artifact deployment, and others.
 |
 | Default: false <offline>false</offline> -->
<offline>false</offline>
<mirror> 
  <id>nexus</id>
  <mirrorOf>*</mirrorOf>
  <url>http://xxxx:8083/nexus/content/groups/public</url>
</mirror>

And here is the error that I get when I try to execute mvn clean install

Failure to find mysql:mysql-connector-java:jar:5.0.5 in
http://xxxx:8083/nexus/content/groups/public

How can I get nexus to load an artifact from my public repositories in nexus? Should I add it manually?

+4
source share
3 answers

You need to tell maven to use your maven repository. To do this, change $ HOME / .m2 / settings.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<settings 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/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://xxxx:8083/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <proxies></proxies>
  <servers></servers>
  <pluginGroups></pluginGroups>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

nexus a bogus URL http://central.

URL- settings.xml, URL- single Nexus group. nexus activeProfiles.

, Central, http://xxxx:8083/nexus/content/repositories/central, http://repo1.maven.org/maven2/, http://central http://xxxx:8083/nexus/content/repositories/central http://repo1.maven.org/maven2/.

pom.xml, mysql-.

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.33</version>
</dependency>

. : Nexus maven

.

+2

, mysql-connector-java? , , , ( , ). ( ), . .

0

All Articles