maven-deploy-pluginని ఉపయోగించడం
మరియు మరొక ఆసక్తికరమైన అంశం సమావేశమైన ప్యాకేజీ యొక్క స్వయంచాలక విస్తరణ. మేము మావెన్ని ఉపయోగించి మా స్వంత లైబ్రరీని నిర్మించుకున్నాము. మేము దానిని స్థానిక, కార్పొరేట్ లేదా సెంట్రల్ మావెన్ రిపోజిటరీకి స్వయంచాలకంగా ఎలా పుష్ చేస్తాము?
Maven దీని కోసం ప్రత్యేక maven-deploy-plugin ప్లగిన్ని కలిగి ఉంది . ఉదాహరణ:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
<configuration>
<file>${project.build.directory}\${project.artifactId}-src.zip</file>
<url>${project.distributionManagement.repository.url}</url>
<repositoryId>${project.distributionManagement.repository.id}</repositoryId>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>zip</packaging>
<pomFile>pom.xml</pomFile>
</configuration>
</plugin>
ఈ సెట్టింగ్లతో, మీరు నిర్మించిన లైబ్రరీని మావెన్ రిపోజిటరీకి చెల్లుబాటు అయ్యే ప్యాకేజీగా నెట్టవచ్చు. మేము ఈ ప్రక్రియను వివరంగా విశ్లేషించము, కానీ ఇక్కడ ఏమి జరుగుతుందో క్లుప్తంగా పరిగణించండి:
ఫైల్ ట్యాగ్ కొత్త లైబ్రరీగా మావెన్ రిపోజిటరీకి నెట్టబడే ఫైల్ను నిర్దేశిస్తుంది.
url ట్యాగ్ అనేది మావెన్ రిపోజిటరీకి మార్గం (స్థానిక/కార్పొరేట్/...).
repositoryId ట్యాగ్ డిప్లాయ్మెంట్ చేయబడే రిపోజిటరీ యొక్క ఐడెంటిఫైయర్ను నిర్దేశిస్తుంది.
groupId , artifactId , వెర్షన్ ట్యాగ్లు మావెన్ రిపోజిటరీలో ప్రామాణిక ప్యాకేజీ గుర్తింపును నిర్వచించాయి. ఈ మూడు పారామితుల ద్వారా లైబ్రరీని ప్రత్యేకంగా గుర్తించవచ్చు.
ఫలితం ఒకే జిప్ ఫైల్గా పంపబడిందని నిర్ధారించడానికి ప్యాకేజింగ్ ట్యాగ్ ఉపయోగించబడుతుంది. మీరు దానిని పేర్కొనకుంటే, మీరు అనేక jar ఫైల్లను కలిగి ఉన్నప్పటికీ, ఒక jar ఫైల్ ఉంటుంది.
pomFile ట్యాగ్ ఐచ్ఛికం మరియు దాచిన లేదా ఓవర్హెడ్ డేటాను కలిగి లేని రిపోజిటరీకి మరొక pom.xmlని పంపడానికి మిమ్మల్ని అనుమతిస్తుంది.
మావెన్ని ఉపయోగించి టామ్క్యాట్కి వెబ్ అప్లికేషన్ని అమలు చేస్తోంది
జావా వెబ్ అప్లికేషన్ల కోసం అత్యంత ప్రజాదరణ పొందిన వెబ్ సర్వర్ Apache Tomcat . మరియు వాస్తవానికి, మావెన్ సహాయంతో, మీరు యుద్ధ ఫైళ్లను నేరుగా స్థానిక లేదా రిమోట్ టామ్క్యాట్ సర్వర్కు అమర్చవచ్చు.
మేము కొంతకాలం తర్వాత టామ్క్యాట్ను ఎలా ఇన్స్టాల్ చేసి కాన్ఫిగర్ చేయాలో నేర్చుకుంటాము, కానీ ఇప్పుడు మేము మా వెబ్ అప్లికేషన్ యొక్క ఆటోమేటిక్ డిప్లాయ్మెంట్ అనే అంశంపై మాత్రమే తాకుతాము.
మొదటి అడుగు. మేము టామ్క్యాట్ సర్వర్కు మావెన్ యాక్సెస్ ఇవ్వాలి. దీన్ని చేయడానికి, Apache Tomcat అన్ప్యాక్ చేయబడిన డైరెక్టరీలో conf/tomcat-users.xml ఫైల్ను తెరవండి మరియు మేనేజర్-గుయ్ మరియు మేనేజర్-స్క్రిప్ట్ పాత్రలను జోడించండి :
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin" roles="manager-gui,manager-script" />
</tomcat-users>
దశ రెండు. టామ్క్యాట్కు మావెన్ యాక్సెస్ను అనుమతించండి. దీన్ని చేయడానికి, $MAVEN_HOME/conf/settings.xml ఫైల్ని తెరిచి , సర్వర్ని జోడించండి:
<?xml version="1.0" encoding="UTF-8"?>
<settings ...>
<servers>
<server>
<id>TomcatServer</id>
<username>admin</username>
<password>admin</password>
</server>
</servers>
</settings>
దశ మూడు. మేము Apache Tomcatకి మా అప్లికేషన్ యొక్క స్వయంచాలక విస్తరణ కోసం ప్రత్యేక ప్లగ్ఇన్ని జోడిస్తాము. ప్లగ్ఇన్ని tomcat7-maven-plugin అంటారు . మార్గం ద్వారా, ఇది మావెన్ డెవలపర్లచే కాదు, టామ్క్యాట్ డెవలపర్లచే సృష్టించబడింది, మీరు పేరు నుండి ఊహించవచ్చు.
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<path>/simpleProject</path>
</configuration>
</plugin>
</plugins>
</build>
కాన్ఫిగరేషన్ విభాగంలో, పేర్కొనండి:
- url అనేది టామ్క్యాట్ నడుస్తున్న చిరునామా మరియు మేనేజర్/టెక్స్ట్కి మార్గం
- సర్వర్ - settings.xml ఫైల్ నుండి సర్వర్ ఐడి
- మార్గం - అమలు చేయబడిన అప్లికేషన్ అందుబాటులో ఉండే చిరునామా
విస్తరణ నిర్వహణ ఆదేశాలు:
mvn tomcat7:డిప్లాయ్ | అప్లికేషన్ను టామ్క్యాట్కు అమలు చేయండి |
---|---|
mvn tomcat7: undeploy | టామ్క్యాట్ నుండి అప్లికేషన్ను తీసివేయండి |
mvn tomcat7:redeploy | అప్లికేషన్ను మళ్లీ అమలు చేయండి |
కార్గో ప్లగిన్తో అమర్చండి
వెబ్ అప్లికేషన్లను అమలు చేయడానికి మరొక ఉపయోగకరమైన మరియు బహుముఖ ప్లగ్ఇన్ కార్గో ప్లగిన్ . వివిధ రకాల వెబ్ సర్వర్లతో ఎలా పని చేయాలో అతనికి తెలుసు. అపాచీ టామ్క్యాట్లో దీన్ని ఎలా ఉపయోగించాలో ఇక్కడ ఉంది:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.9.10</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<type>installed</type>
<home>Insert absolute path to tomcat 7 installation</home>
</container>
<configuration>
<type>existing</type>
<home>Insert absolute path to tomcat 7 installation</home>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
మీ స్థానిక టామ్క్యాట్లో వెబ్ అప్లికేషన్ను ఇన్స్టాల్ చేయడానికి, మీరు ఆదేశాలను అమలు చేయాలి:
mvn install
mvn cargo:deploy
మేము రిమోట్ వెబ్ సర్వర్కు అమలు చేయాలనుకుంటే, మేము ఈ సర్వర్కు యాక్సెస్ హక్కులను సెటప్ చేయాలి. దీన్ని చేయడానికి, మీరు వాటిని pom.xml లో నమోదు చేసుకోవాలి :
<configuration>
<container>
<containerId>tomcat8x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>admin</cargo.remote.password>
<cargo.tomcat.manager.url>http://localhost:8080/manager/text</cargo.tomcat.manager.url>
</properties>
</configuration>
</configuration>
IntelliJ IDEAతో అమలు చేయండి
Intellij IDEA అన్ని పనులను స్వయంగా చేస్తుంది, మీకు కావలసిందల్లా ఇన్స్టాల్ చేయబడిన టామ్క్యాట్ .
మొదటి అడుగు. స్థానిక టామ్క్యాట్ కాన్ఫిగరేషన్ను సృష్టించండి:

దశ రెండు. ఆపై స్థానిక టామ్క్యాట్ని ఎంచుకోండి:

దశ మూడు. టామ్క్యాట్ని కాన్ఫిగర్ చేస్తోంది:

దశ నాలుగు. టామ్క్యాట్ ఫోల్డర్కు మార్గాన్ని జోడించండి.

దశ ఐదు. మేము మా ప్రాజెక్ట్ను టామ్క్యాట్కు ఒక కళాఖండంగా జోడిస్తాము.
దీన్ని చేయడానికి, విస్తరణ ట్యాబ్కు వెళ్లి, కుడి వైపున ఉన్న + బటన్ను క్లిక్ చేయండి .

అంతే.
మార్గం ద్వారా, మీరు రిమోట్ సర్వర్కు డిప్లాయ్ చేయవలసి వస్తే, రెండవ దశలో రిమోట్ టామ్క్యాట్ని ఎంచుకోండి.
GO TO FULL VERSION