Choose Hibernate url and nexus snapshot repository dynamically while deploying artifact to Nexus server with Maven build or profiles
NickName:user1926688 Ask DateTime:2015-06-11T13:06:25

Choose Hibernate url and nexus snapshot repository dynamically while deploying artifact to Nexus server with Maven build or profiles

I have a database project which uses hibernate and is deployed as a snapshot to Nexus server. But I want to change url , username and password for test and production environment. Is there a way so that I can change properties of my hibernate.cfg.xml while maven build and then deploy it to nexus server and choose between two repositories to which I can deploy the artifact ?

like

<distributionManagement>
        <snapshotRepository>
            <id>snapshots</id>
            <url>http://nexus:3344/nexus/content/repositories/snapshots</url>
        </snapshotRepository>
        <snapshotRepository>
            <id>Project</id>
            <url>http:/nexus:3344/nexus/content/repositories/Project</url>
        </snapshotRepository>
    </distributionManagement>

Hibernate.cfg.xml

<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>

    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://MyDatabase:3344/project</property>
        <property name="hibernate.connection.username">username</property>
        <property name="hibernate.connection.password">password</property>
        <property name="show_sql">true</property>
        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hbm2ddl.auto">validate</property>
        <property name="hibernate.c3p0.max_size">30</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.timeout">600</property>
        <property name="hibernate.c3p0.aquire_increment">2</property>
        <property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
        <mapping class="com.jts1.db.dto.AddNewUserDTO" />
        <mapping class="com.jts1.db.dto.AddProjectDBDTO" />
        <mapping class="com.jts1.db.dto.AssignProjectsDTO"/>
        <mapping class ="com.jts1.db.dto.IssueDBDTO"/>
        <mapping class ="com.jts1.db.dto.AddCommentDTO"/>
    </session-factory>
</hibernate-configuration>

Copyright Notice:Content Author:「user1926688」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/30772002/choose-hibernate-url-and-nexus-snapshot-repository-dynamically-while-deploying-a

More about “Choose Hibernate url and nexus snapshot repository dynamically while deploying artifact to Nexus server with Maven build or profiles” related questions

Choose Hibernate url and nexus snapshot repository dynamically while deploying artifact to Nexus server with Maven build or profiles

I have a database project which uses hibernate and is deployed as a snapshot to Nexus server. But I want to change url , username and password for test and production environment. Is there a way so...

Show Detail

Maven ant tasks deploying to public nexus repository instead of the url specified

I am stumped. I am using ant and maven-ant-tasks to build and deploy snapshot artifacts (non-maven) to a remote nexus repository. The build process specifies the url of the repository. This is the ...

Show Detail

Deploying jar to Nexus using Maven Ant Task

I am going completely mad here. I am simply trying to upload a jar to a Nexus server using Maven Ant Task but when I run the build.xml file using ant I get the following error Deploying to http://...

Show Detail

Deploy SNAPSHOT artifact and sources to Nexus from Maven command line

I am trying to deploy one EXE file and it's zipped source file to Sonatype Nexus using maven command line. Files must be deployed as SNAPSHOTs. So, I have 2 files: -testXYZ.exe and source file -t...

Show Detail

How to download snapshot artifact from internal Nexus?

I have a Nexus internal server and I defined an internal shapshot repository and the release one. Their ids are: Snapshots and Releases and they are hosted repository. I configured a Group Reposit...

Show Detail

Could not find artifact when deploying artifact to Nexus

I am deploying an artifact to a Nexus snapshot repository that allows redeployment, using the maven command: mvn deploy:deploy-file -Durl=https://t-nexus.perque.com/service/repository/t-PASTIS -

Show Detail

Release a snapshot to nexus using maven 3.0.5

I am unable to release a snapshot version of an artifact which I build using maven to nexus. The version of my artifact states 1.0.0-SNAPSHOT. I can execute mvn clean install without an issue. But...

Show Detail

Could not find artifact (snapshot) in Nexus repository

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 pro...

Show Detail

Issues with deploying artifacts in Nexus repository

We are in the process of deploying artifacts into the nexus repository and facing issues. Issue we are facing issues with Nexus integration. We have included &lt;distributionManagement&gt; tag i...

Show Detail

How to upload artifact after Jenkins build to Nexus

I have a project structure like this: - parent-project : pom.xml + child-project: pom.xml + child-project-2: pom.xml I would like to upload the artifact of child-project to Nexus, so in pom....

Show Detail