Spring boot on IntelliJ - java

this is my first time ever working with a framework, I decided to learn Spring Boot to create a web app project.
I have followed some tutorials, and the steps were (for most of the videos):
go to start.spring.io, add the "Spring Web" dependency, select Maven project and then download the zip file.
import the project on IntelliJ as a Maven project.
But the problem is that, as shown in the screenshots:
it says: Cannot resolve symbol 'springframework'
screenshot 1
and as for the POM file,
"Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.5.2 from https://repo.maven.apache.org/maven2 was cached in the local repository"
as well as: Project '...' not found
Dependency '...' not found
Plugin '...' not found
screenshot 2
Please let me know, what steps did I miss.
Thank you

Make sure that you can access "https://repo.maven.apache.org/maven2". And check the HTTP proxy settings from Preferences | Appearance & Behavior | System Settings | HTTP Proxy. Select No proxy if you don't need it for accessing the Maven repo. Also, try to disable the downloaded 3rd party plugins temporarily and restart your IDE.

Related

Cannot resolve symbol 'google' for Cloud Vision API

I'm trying to get Google Cloud Vision API working with Java in IntelliJ. I've followed all the steps at https://cloud.google.com/vision/docs/quickstart-client-libraries. I'm running the following code, just trying to import the packages I need and when I scroll over google, it is underlined in red and says 'cannot resolve symbol google'. How do I fix this?
code and error
The error shown in your screenshot usually happens when an external dependency could not be loaded.
Please make sure you accurately followed the steps in the Install the Client Library section of the guide you followed, in the Java tab of the widget.
From the screenshot I can not really tell what build settings you configured for the IntelliJ project. If you chose no build tools or the regular Ant setup, it might be easier for you to re-setup a project based on either Maven or Gradle.
With Gradle and Maven it is pretty straightforward to add the dependency to the project as described in the guide, otherwise you will have to download all the dependency libraries yourself and add them to your project folder and build environment manually as files.
If you did already use Gradle or Maven for your project, and did follow the guide but it still shows the error, then it's usually a case of IntelliJ not loading those changes yet.
In that case you can fix it by selecting your Gradle or Maven tab in Intellij, and clicking the re-import button (looks like a refresh icon from browsers) to reload the configuration, usually triggering a download of missing dependencies.
Otherwise you can also trigger a full build with running the gradle build or mvn compile targets, which also should download all configured missing dependencies.

Creating a Spring MVC project using Intellij 2020

i'm trying to create a spring MVC project using intellij Ultimate 2020 but i don't have it available in my menu :
Is there a way to get the Spring option ? i already checked that the Spring plugins are all enabled .
The Spring Initializr can generate a Spring Boot project structure for you. It will give you a basic project structure and either a Maven or a Gradle build specification to build your code with.
You can use Spring Initializer to generate a spring project. It will provide you with all the dependencies required for SpringMVC project
Go to https://start.spring.io/.
Just specify the dependencies.
Download the generated project.
Open the project with IntelliJ.
Resolve the dependencies by specifying the unmet ones in pom.xml if found any.
Good to go!
I don't know are u new in spring, but if u are, here some advice to start in idea.
First of all, visit https://start.spring.io/
First 5 steps of instruction matches with numbers on this picture
https://i.stack.imgur.com/T6NW1.png
Choose dependencies u need, for example start with spring web(mvc)
Choose your language, u need java
Choose which dependency manager u will use, for example maven
Choose spring boot version, for example 2.3.3
Give a proper name to your future project, it's not necessary
Press GENERATE
Unzip downloaded file
IntelliJ Idea -> Open or Import - > select unziped folder

Deploying Maven project - Unable to add jersey archetype

I want to set up a environment to write a RESTful web service program. Using RedHat JBOSS developer studio, I was trying to create.
File --> New Project --> Maven Project --> Next(skipping workspace) --> Select an archetype.
I need to select jersey archetype, which is not listing in the 'all catalogs' , I have added the following URL using remote method to download the jersey.
http://repo1.maven.org/maven2/archetype-catalog.xml
Getting this error when I am adding manually.
Manually adding
Can't resolve Archetype org.glassfish.jersey.archetypes:jersey-quickstart- webapp:2.23.2
org.eclipse.core.runtime.CoreException: Could not resolve artifact org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.23.2
Attaching the snapshot for clear understanding.
Please help me to sort this.
Is your network blocking access to above URL ?
You can try find jar file in other source and add to project.

The container 'Maven Dependencies' references non existing library - STS

I'm using win8 previously I had been running Eclipse Juno on my pc but from now on I wanted to start using STS, I am getting the below error as soon as I create a new project. I deleted my .m2 folder and everything related to Eclipse in order to start over from scratch still didn't work, I've ran out of ideas. Any advice???
Can not find the tag library descriptor for "springframework.org/tags" index.jsp /app/src/main/webapp line 6 JSP Problem
The container 'Maven Dependencies' references non existing library 'C:\Users\Pablo.m2\repository\org\springframework\spring-webmvc\3.2.3.RELEASE\spring-webmvc-3.2.3.RELEASE.jar' app Build path Build Path Problem
The project cannot be built until build path errors are resolved app Unknown Java Problem
ArtifactTransferException: Failure to transfer antlr:antlr:jar:2.7.7 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact antlr:antlr:jar:2.7.7 from/to central (http://repo.maven.apache.org/maven2): No response received after 60000 pom.xml /app line 1 Maven Dependency Problem
22 more errors like this for each of my dependencies...
Class 'org.springframework.web.servlet.view.InternalResourceViewResolver' not found [config set: app/web-context] mvc-config.xml /app/src/main/webapp/WEB-INF line 16 Spring Beans Problem
So I get you are using Eclipse with the M2E plugin. Try to update your Maven configuration : In the Project Explorer, right-click on the project, Maven -> Update project.
If the problem still remains, try to clean your project: right-click on your pom.xml, Run as -> Maven build (the second one). Enter "clean package" in the Goals fields. Check the Skip Tests box. Click on the Run button.
Edit: For your new problem, you need to add Spring MVC to your pom.xml. Add something like the following:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
Maybe you have to change the version to match the version of your Spring framework. Take a look here:
http://mvnrepository.com/artifact/org.springframework/spring-webmvc
I got the same problem and this is how i solved. :
Right click your Spring MVC project, choose Run As -> Maven install.
Observe the output console to see the installation progress. After
the installation is finished, you can continue to the next step.
Right click your Spring MVC project, choose Maven -> Update Project.
Choose your project and click OK. Wait until update process is
finished.
The error still yet, then do Project->Clean and then be sure you have selected our project directory and then do the follow Project->Build.
Although it's too late , But here is my experience .
Whenever you get your maven project from a source controller or just copying your project from one machine to another , you need to update the dependencies .
For this Right-click on Project on project explorer -> Maven -> Update Project.
Please consider checking the "Force update of snapshot/releases" checkbox.
If you have not your dependencies in m2/repository then you need internet connection to get from the remote maven repository.
In case you have get from the source controller and you have not any unit test , It's probably your test folder does not include in the source controller in the first place , so you don't have those in the new repository.so you need to create those folders manually.
I have had both these cases .
I'm a little late to the party but I'll give my two cents. I just resolved this issue after spending longer than I'd like on it. The above solutions didn't work for me and here's why:
there was a network issue when maven was downloading the required repositories so I actually didn't have the right jars. adding a -U to a maven clean install went and got them for me. So if the above solutions aren't working try this:
Right click on your project -> Choose Run as -> 5 Maven build...
In the Goals field type "clean install -U" and select Run
After that completes right click on your project again and choose Maven -> Update Project and click ok.
Hope it works for you.
I finally found my maven repo mirror is down. I changed to another one, problem solved.
Today I had this same problem with another jar. I tried multiple things people said on Stackoverflow, but nothing worked. Eventually I did this:
Close eclipse and any project-app that is running.
Delete the .m2 folder (Users --> [your_username] --> .m2). It's an invisible folder, make sure you are able to view invisible folders.
Restarted Eclipse (I guess it works in other IDE too) and updated my project.
Now it works again for me. Perhaps this solves the problem for someone else too.
I have solved it using "force update", pressing Alt+F5 as it is mentioned in the following link.
In Eclipse adding to the #Saket Mittal response.
Run As > Maven build...
Set goals clean install and run

spring MVC sample web app

I'm looking for an example Spring MVC 2.5 web app that I can easily:
Setup as a project in Eclipse
Deploy to a local app server (using Ant/Maven)
There are a couple of example applications included with the Spring distribution ('petclinic' and 'jpetstore'), but they don't provide any Eclipse project files (or a way to generate them). They also seem a bit complicated for my needs, e.g. require a local database to be setup.
The easiest way to get up and running with a Spring MVC project is to use SpringSource Tool Suite, which is another free IDE based on Eclipse.
The integration between the IDE and Spring/Maven is tight, and it comes with an application server already setup for you to deploy your web app.
Follow these steps to get a working Spring MVC web app.
To setup a new project in STS: Click File -> New -> Spring Template Project -> Spring MVC Project
To pull in dependencies and compile your project: Right click your new project -> Run As -> Maven install
To run your project inside an application server: Right click your new project -> Run As -> Run on Server -> SpringSource tc Server
If it works, you'll see a web page saying "Congratulations! You're running Spring!"
While not specifically an app you can download, Developing a Spring Framework MVC application step-by-step covers creating a spring application in Eclipse with an ant build script, complete with unit tests.
This meets the following requirements:
Spring MVC 2.5
Project in Eclipse
Deploy to a local app server using Ant
Uses HSQL (no need to install a local DB)
There's a Maven archetype (template project structure) for Spring MVC here:
http://docs.codehaus.org/display/MAVENUSER/Archetypes+List
That's a good starting place for this kind of investigation. To create an archetype using Maven, first install Maven:
http://maven.apache.org/plugins/maven-install-plugin/
and then create a project using the archetype:
http://maven.apache.org/guides/introduction/introduction-to-archetypes.html
You can also use the m2eclipse plugin for Eclipse to simplify this and it takes you through the stages of the project using a wizard. Just right click -> New Project -> Other, Maven and select the archetype. Hope that helps.
Just spotted http://blog.springsource.com/2010/07/22/spring-mvc-3-showcase/ which could be interessting for you.
To generate Eclipse project files:
Use mvn eclipse:eclipse before importing the project into your workspace. This will create all required configuration files and hook your project up with all the required dependencies.
The mvc-basic and mvc-ajax sample projects in spring-samples (SVN URL: https://src.springframework.org/svn/spring-samples) are simple projects that do not need any local database support.
Use AppFuse
I got it working just as Drew described, but there is a trap for new users (meaning fresh install, no familiarity with Maven or m2eclipse). You'll get this error:
[ERROR] Error executing Maven.
[ERROR] The specified user settings file does not exist: /home/user/.m2/settings.xml
And the work around is to just make an almost empty settings.xml:
<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">
</settings>
(I later found this bug report.)
After that, I was in business. I was even able to export as a WAR file and deploy onto my installation of WebSphere Community Edition. Thank you, Drew!
A little less earlier, I wrote:
Hmph. Never mind. I gave up, shut down my machine, and when I came back, everything worked (except for a minor Maven issue I'm working on). Chalk it up to a bug.
Earlier, I wrote:
I was very excited to hear about STS, so I downloaded and installed it. It went perfectly. This is a new machine, so I have the latest of everything - java 1.6, eclipse 3.5.1, etc.
On step 2 of the above instructions, I get this error:
"The specified JRE installation does not exist"
I've set paths everywhere I can find, so I'm not sure which JRE it's complaining about. Help?
You could also use Spring Roo to do this. http://www.springsource.org/roo
You can use below link to download hello world spring mvc project
Spring MVC hello world example

Categories