Spring Boot project in IntelliJ community edition - java

I am new to IntelliJ Community edition. Can anyone help me with creating spring boot project in intelliJ Community edition. For ultimate edition there is spring-boot initializer but I cannot find anything for community edition. I followed this links but cannot find any solutions
"Create Spring Boot Project with IntelliJ Community (FREE) Edition in 5 mins"
"Getting Started with SpringBoot in Intellij IDEA Community Edition"

You can install a plugin called Spring Assistant:
Now you can use the initializer as:
Personally, however, I use Spring initializer at start.spring.io
EDIT: Adding run configuration
Select Edit Configuration from the Run menu
Now in the dialog box, lick on the + button and select Application.
Now you just need to provide the name of the main class. You could click on the browse button(...) to get a list of files having main(...).

If you have done your spring project with SPRING IO
Then You can import it as maven project and follow this steps to import spring project
Open IntelliJ IDEA
You can see Welcome screen, click Import Project.
The Select File
Navigate to your Maven project and select
Click OK.

Pretty simple, as both link you attached say you created your project with Spring Initializr, and if it is a maven project, then follow these steps mentioned below:
click on File option
click Open option
navigate to your project and choose pom.xml file [it not a maven project, choose your configuration.xml file, if something else, just select the project folder]
press Ok. And you are done
now, open idea terminal and run mvn clean install(I assume you have installed maven) or, just select project->right click->choose maven-> click on Reimport maven option. Now run mvn clean build All are set now.

You can follow these steps.
Click on Add / Edit configuration
Then select configuration type as application.
Fill in appropriate details.
Note: In place of <no module> add directory / module in which the entry class is present.
Save the configuration and click on Run / Debug symbol shown in first screenshot.

Extending #Prashant's answer
If you are not able to find Spring Assistant plugin within IntelliJ Community Edition, Go to Plugin's website and then click on GET button, Choose Compatibility with IntelliJ IDEA Community and then click Download.
The rest of the procedure remains the same as described by #Prashant.
Also if you want to change your Port, then select Modify Options and select Add VM Options, and paste
-Dserver.port=8090
in that VM Options textbox and then run the application.

Just go to the below mentioned:
https://start.spring.io/
Fill the information regarding Project(Maven, Java, spring-version(Select version only
have digits(for eg:2.6.2))). Don't select "snapshot" version.
Fill project Metadata information and click on Generate file. It will create jar file. Unzip it and open your IntelliJ and select "Open->select this Unzip folder and select "pom.xml" file inside this package and open as project.

Apart from the spring initialiser, in my experience no where else do you need an ultimate edition to work with spring boot, you can use Spring Intialiser
But there is a plugin as rightly mentioned by other Spring assistant which you can download from the plugin section which you can access from setting inside intellJ Idea.
For configuration instead of actually going in the edit configuration option of intellJ Idea you can just run the application and that would automatically have your configuration loaded and there onwards you can always use it.

Related

Spring boot project imported in intellij not working

I have imported spring boot project generated from spring boot initialiazr website and the project spring boot packages are not found.
Please seee the image below
Please help
I tried this and it worked, "Right click on the pom.xml file", and select "Add as maven project"
It should resolve or reimport all the dependencies, and it should work.
You need to download libraries so right click project, go to "Maven" option in menu then click "ReImport" or "Download Sources and Documentation" option in sub menu. It will download libraries.
My problem is fixed.
It was my proxy settings problem.
I made right clic on IntelliJ=>Maven=>Open Settings.xml
I update settings xml file by adding
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>myproxyhost</host>
<port>myproxyportnumber</port>
<username>myproxyusername</username>
<password>myproxpass</password>
<nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
</proxy>
</proxies>
I downloaded a simple project from Spring IO . But Intellij Idea could not import it properly. Somethings were wrong. It had been seem like it could not understand it is maven project. I changed Maven home path from "Use maven wrapper" to "Bundled" in File | Settings | Build, Execution, Deployment | Build Tools | Maven. And it re-initiate the project and it downloaded the dependencies. screenshot of settings
You need to download all of the spring-boot dependencies, and because I see pom.xml in your project I assume you're using Maven as build tools. In order to download the dependencies you can execute command mvn clean install on your command line.
I'm sorry I'm not very familiar with Intellij, but you can also execute Maven command in Intellij you can check the documentation
I had the same issue and the following worked for me
Delete the .idea folder inside the project
Then add the Java SDK for your project
In IntelliJ Idea: File --> Project Structure --> Project SDK add the Java SKD -->OK
Next you have to restart the IntelliJ Idea
I realize this is an old question, but just in case it helps someone else:
If you have more than one Java sdk installed you need to specify the java version you want to use before you can rebuild.
In IntelliJ Idea: File --> Project Structure --> Project
Select your Project SDK, then rebuild the project
that worked for me...
I used this way:
I created 2 folders in documents for exemple : MyProject -> Project ... before opening your folder you should choose "Project" as I write. The problem is choosing wrong main folder
I recently faced this issue after use IntelliJ IDED after few months.
When import project with existing source files or new which download from spring initializr, we should click open project. Should not use new project.
Hardly I wasted 1 day time to display hello world text using spring boot rest get api call.
For Spring Initializer Project,
Extract downloaded zip file from https://start.spring.io in corresponding folder.
Open intelliJIdea application, you can reach "Welcome To IntelliJIdea" displaying with recent projects.
Click Open in the top right side of the same window. Select desired folder path of the project and continue the steps.
Hope now you can run project without "Springbootapplication not found" error

STS, running any of the Guide projects

I install Spring Toolsuite.
I go to New -> Import Getting Started project.
I choose the 'Building a RESTful Web Service' one. Download only the 'complete' project, select maven and not to open the site.
Now what on earth to I have to do to launch it? Right-click on the project, run as, run on server, shows 'The selection cannot be run on any server'.
I have gone through loads of posts trying to find out what else I can do, done maven clean, maven install, changed the JRE Environment, nothing works.
Running a maven clean or maven install will only update the dependencies of the project (for instance, bring in Spring and its child dependencies, loggers, etc. specified in the pom.xml file).
To run the project right click on the class with the #SpringBootApplication
annotation (it will likely be the one with a main method in it, that's the one you want!). Then select 'Run as->Java Application'.
First a disclaimer. This answer applies to most of the guides. But there may be some to which it doesn't apply, because there's such a diversity of guides available.
Assuming you are trying a 'typical' guide which does something in the context of a web-app... then read on.
The reason that you can not run a guide with "Run On Server" is because of spring-boot adheres to the slogan of "Make Jar not War". The guide sample code are not things you deploy on a server (i.e war) but are standalone Java apps (i.e. jar) which contain their own embedded servlet container (if they need one). That means running them is really quite simple. Just find the 'main' method/class in the guide and use Eclipse "Run As >> Java Application".
There's also a convenient alias in STS called "Run As >> Spring Boot App" which does pretty much the same thing but gives you a few extra bells and whistles in the launch configuration editor.
Also... you don't really have to go look for the main method yourself because the "Run As >> Spring Boot App" knows how to find it in most cases. So clicking project and "Run As >> Spring Boot App" should do the trick.

Error while creating Maven project In Eclipse using archetype selection

When I am trying to create maven project it is showing below error
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories.
Please help me with the solution.
Please check if you configured your maven in eclipse properly
1. Go to preference-->Maven-->Installation
In this add the path of working maven directory
2. Go to preference-->Maven-->User Setting
In this add the path of your maven_directory/conf/setting.xml
Try with these setting let us know if it works...cheers
If you are using eclipse luna EE version,
GO TO
Windows -> Preferences -> Maven and uncheck the following option
Do not automatically update dependencies from remote repositories.
This option is checked by default.
You need to add maven archetype catalog to eclipse
Window>Preferences
Maven>Archetypes
Add Remote Catalog and add the following:
Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xml
Description : maven catalog
After adding archetype,restart eclipse.
If you are using Eclipse over Windows 7, then make sure you are running eclipse with enough privileges (Run as administrator). Furthermore, configure the Proxy settings for MAVEN as folks stated in the previous answers, and make sure that Eclipse Proxy settings are set too.
Just check the checkbox coming on first popup while creating Maven module.
Checkbox name - "Create a sample project(skip archetype selection)" and go ahead with rest of the procedure, you will not get any errors.

Problem with running Maven GWT application in Eclipse

I'm trying to create a GWT project through WebAppCreator enabled Maven2.
Project creation steps:
Create project with WebAppCreator (i'm using gwt-2.3.0) ->webAppCreator -noant -maven -XnoEclipse -out MyApp com.example.MyApp
Import project as existing maven project in eclipse (helios)
Enable "Project" -> "Properties" -> "Google" -> "Google web toolkit" -> "Use google web toolkit" checkbox
Set in project properties "Google" -> "Web application" -> "This project has a WAR directory". Set WAR directory path "src/main/webapp" and uncheck "launch and deploy from this directory"
Java build path is "MyApp/target/www/WEB-INF/classes"
I did not change the settings in pom.xml
Compile project using gwt eclipse plugin (2.3.0 version). It successfully compiled.
Try to run project as Web Application. When i run application GWT plugin does not ask me about WAR folder.
I did all this, I saw in the logs:
[WARN] Server class 'com.example.server.GreetingServiceImpl' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/home/redfox/workspace/java/redfox/MyApp/target/www/WEB-INF/classes/' to the web app classpath for this session
[WARN] Server class 'com.google.gwt.user.client.rpc.RemoteService' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/home/redfox/.m2/repository/com/google/gwt/gwt-servlet/2.3.0/gwt-servlet-2.3.0.jar' to the web app classpath for this session
And when i try to load page from URL (http://127.0.0.1:8888/MyApp.html?gwt.codesvr=127.0.0.1:9997) i see 404 error.
In logs i don't see any errors. How can i run this default application? Also i have another question: if this problev will be solved, how can i run this application in web mode (not in development mode) for using links like "http://127.0.0.1:8888" whithout param gwt.codesvr?
P.S. Sorry for my bad English.
I understand your frustration, trust me, I recently went through exactly the same issue you having now.
As Eugene indicated, follow his instructions, but...
On the Select an Archetype choose version 2.3.0-1 (Others may work but this one works for me)
Generate your sample app using theat Archtype version. Do a mvn gwt:run, you will see this screen (If all goes well)
Click on "Launch Default Browser".
Good luck.
Cheers
PB
I know this question is two years old. But i just had the same issue and now figured out how to fix it.
When eclipse doesn't ask you at the first launch for your "WAR" directory, you can also set it manually:
In eclipse go to "Run" -> "Debug Configuration...". Select your "Web Application" -> Select the "Arguments"-Tab and add the parameter e.g. "-war C:\YourProjectPath\target\YourProject-1.0-SNAPSHOT". Provide the full path here pointing to your target, generated by maven.
Hope that helps someone solving this issue faster :)
I know this is old, but here is my latest approach (as also answered here)
I can't speak for the webAppCreator because I haven't used it, but I have had good luck creating the Maven projects in Eclipse using the gwt-maven-plugin from codehause.
Creating a Maven GWT Project Directy in Eclipse
Open the new project wizard in Eclipse and filter on Maven Project.
Select the Maven Project and click next.
Enter the project location of your preference and click next.
Enter "gwt-" into the archetype filter and select the gwt-maven-plugin from codehaus. Click Next.
Enter your maven project details and a module value, then click Finish.
This will create a maven - gwt project for you in Eclipse. This comes with a sample application that you can use to make sure you can launch the application correctly.
Running the Application Command Line
Open command line.
Navigate to your project home.
Run the command "mvn clean package".
Run the command "mvn gwt:run"
This should get you up and running. If you used the 2.7.0 gwt-maven-plugin this should run the application in super dev mode by default.
Run the application in Eclipse
As you have done, navigate to Properties > Google > Web Application and check "This project has a WAR directory". The WAR directory using this plugin should be src/main/webapp.
Navigate to Properties > Google > Web Toolkit and check "This project has a WAR directory. You may be able to specify the module here. I am actually unable to do so, it may be specific to my Google Plugin for Eclipse or something environment specific...
Run As > Web Application.
If you had issues, as I have had, in step 2 then you will get an error Missing required argument 'module[s]'. To fix this open up your run configuration (should have been auto created) and in the arguments tab add the package qualified name for your module at the end of the arguments, e.g. com.mycompany.abc.GwtSampleModule. Do not add the ".gwt.xml" prefix.
It's worth also checking that the HTML page referenced in your arguments is correct, I have also had issues with that.
The application should now be configured for Launch in Eclipse using this run configuration. My verified environment is:
Eclipse Luna (v4.4)
Google Plugin for Eclipse (v3.8)
GWT Maven Plugin (v2.7.0)
What I suggest may start slightly different than you prefer but with better results :)
Install m2eclipse plugin. This will add a lot of nice maven features to your environment.
Using new project wizard create new Maven project
Do not select "simple project" check box, instead use the one of GWT archetypes (I suggest gwt-maven-plugin)
Then appropriate project structure with all required dependencies will be created for you by maven. More info about GWT plugin can be found at http://mojo.codehaus.org/gwt-maven-plugin/user-guide/archetype.html, including on how to execute it.
P.S. Your English is fine :)

Tomcat throws ClassNotFound exceptions for classes in other open eclipse projects

I have an eclipse project structure that looks something like this:
eclipse
project a
project b
All of these projects are Maven projects. Project B is an Eclipse WTP project and contains Project A as a dependency. I'm using the m2eclipse plugin.
When I deploy Project B to Tomcat (all from within Eclipse) it always throws errors saying that it can't find classes from Project A. The only way I can resolve this is to close Project A in Eclipse and do a mvn install command, so at this point Project A is treated like any other dependency.
I would like to not have to keep reopening and then closing Project A every time I make changes to it (which is pretty frequently at this stage).
I have tried adding Project A to Project B's Build Path, however that doesn't seem to do the trick. Again, it only works if I close the project in eclipse so it's treated like a normal maven dependency.
FYI I'm using the Helios version of Eclipse. Project B is a Spring project, so naturally Tomcat falls over when it imports all the beans etc.
Does anyone have any suggestions? Thanks a lot.
What you need to do is this:
In Eclipse go to Window > Show View > Servers > and open tab called Servers
In Servers, double click the server you want
This action should open a window entitled Overview, with your selected Server in the TAB
In this window select: Open launch configuration, and click the link.
In the Edit Configuration window, select the tab called Classpath
In the ClassPath textbox, select the line: User Entries
Now push the button on the right entitled: Add Projects
In the resulting Project Selection window select the external project you want the server to find via click.
Close these windows by clicking Apply then OK as appropriate as you work up the stack
Restart your server in the Overview window
You should be ready to go. It's actually only a 2 minute exercise. Good luck
If you go to the project properties, pick the item "Deployment Assembly", click "Add..." and choose "Project", you can add the dependent project and the issue should be solved.
The reason that tomcat cannot find your classes is that the project dependency in eclipse is not seen by tomcat. To resolve the issue you can add the bin folder of project a to the tomcat classpath of the app running from project b.
Right click on the web project which is added to container server and select Maven and then select Disable Workspace Resolution. Then your dependency project will start appearing as a jar like any other dependencies.
Right Click on the WebProject --> Maven --> Disable Workspace Resolution.
Have you installed the m2eclipse extension that know about WTP? Without it m2e will not work correctly for WTP projects. See this:
https://docs.sonatype.org/display/M2ECLIPSE/WTP+mini+howto
Simple way :
Run -> Run Configurations... -> Classpath

Categories

Resources