About Me

My photo
India
Hey there, lovely people! I'm Hemant Menaria, and I'm passionate about programming. Having completed my MCA in 2011, I've delved into the world of coding with fervor. I believe in sharing knowledge, making complex concepts easy to grasp for everyone. JAVA, PHP, and ANDROID hold a special place in my heart, and I spend most of my time immersed in them. Currently, I'm deeply engaged in API/Webservice frameworks and crafting Hybrid mobile applications to enhance flexibility in the digital realm. If you ever find yourself stuck with a programming challenge, feel free to reach out to me at +91-8955499900 or drop me a line at hemantmenaria008@gmail.com. I'm always eager to help fellow enthusiasts navigate the intricacies of coding!

Sunday, April 26, 2020

Various error during maven configuration with java spring



Q1- During project Creation or Maven Update or if Pom.xml showing any error or dependecy jar not loading then-
Solution:  Go to User Profile Foler =>.m2=>delete .lastupate.

if you unable to find User Profile folder then follow below steps-
1-Open folder by running this text (without Quotes) in Search Explorer of Window “%USERPROFILE%.m2”.
2-After running above command, “m2” folder of maven will open. Now search for file (without Quotes) “*.lastUpdated”.
3-In this step, delete all the files found by running Step 2.
4-Now go to Eclipse project and select “Maven | Update Dependency” or “Maven | Update Project”
5-If you still facing error then close eclipse and delete .m2 folder and try again.

-----------------------------------------------------------------------------------------
Q2- Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central
or
ArtifactTransferException: Could not transfer artifact
or
How to create settings.xml
Solution: Create settings.xml file in User Profile Foler =>.m2 folder.  ( if you are unable to fine user profile folder then see Q1 (above).
To create settings.xml file-> open notepad-> paste below code-> save as-> File Name- settings.xml. Save As Type- All and Save.

<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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<offline>false</offline>
</settings>
---------------------------------------------------------------------------------

Q3- tomcat:deploy: “Cannot invoke Tomcat manager: Connection refused”
Solution: Before deploying of project make sure following-
For tomcat7 or tomcat 8 do the following-

1- Project- pom.xml

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://localhost:8080/manager/text</url>       
        <path>/projectName</path>
        <username>tomcat</username>
        <password>tomcat</password>
    </configuration>
</plugin>

2- TomcatDirectory\conf\ tomcat-users.xml: Add below line in  section
<role rolename="manager-gui"/>
  <role rolename="manager-status"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <user username="tomcat" password="tomcat" roles="manger-gui,manager-status,manager-script,manager-jmx"/>
it will show like this-
Now run project and deploy it (Right Click on project=>Run as=>Run Configuration)
Gole:- clean install tomcat7:deploy   (For first time deployment) and for next time use clean install tomcat7:redeploy
Profile:-Leave Blank
Gole:-Default or path (if you have created settings.xml)




No comments:

Post a Comment