my class of spring boot start located in an external jar.This external jar is a dependency for this project.When I try to create a configuration of Spring Boot in IntelliJ, it saying that it cannot access this class.
I added in pom.xml a tag of the main class, and running it through plugin of maven Spring Boot, and everything work, but its annoying, because every change I need to run install.When I open the jar via dependency window in IntelliJ, I can see this class and have an option of run , and if you press run IntelliJ says cannot find spring boot class to run.
Check: Project Settings | Maven | Importing | Import Maven projects automatically.
Plus, in the maven tab, you can add external projects as direct dependency (the green '+' button). There you have to select your project that you also added as pom.xml
Then you only have to run mvn install on the external project if you want to build the jar/war for your impl project. But within the IDE not need to execute installs.
In new version you have check box of include provided dependices.Check it and will work
Related
I get a spring boot with maven project from github, which works well in my teammates computers. I am using Intellij idea and I am confused about how to run it in my computer. Should I initialize a project or can I just use the project directly by open folder?
In edit configuration part, I choose maven and the directory containing pom.xml. In that case it gives noGoalsSpecified error. So should I include a goal in command line part of edit configuration. In short, how to run the project?
I have created a Spring Boot application using Spring Intializr extension of VS Code.
Configuration, Build Tool : maven, Language : Java, groupId : com.example, artifactId : springdemo, Spring boot version : 2.0.3, I have selected 2 dependencies which are Spring MVC and Spring DevTools Core from the dropdown.
Here is the screenshot Screenshot of the selected dependencies
After importing it and opening the folder structure Project Structure after vs code imports the maven project and opens up the folder
After this I ran a command
chmod 777 mvnw
to give permission to the gradle wrapper and after that
./mvnw clean install
This seems to work fine logs after the ./mvnw clean install command
This is my pom.xml
My pom.xml contains
Here is the difference : My VS Code project does not contain the maven dependencies folder as in case of eclipse and even after install all the packages vs code does not seem to recognize the packages and shows error
errors in vs code
This is how my eclipse project structure look like eclipse project structure contains the maven dependencies
The final result is a running project. The project runs even from vs code by ./mvnw spring-boot:run
but I am unable to get any kind of IntelliSense from VS Code and although eclipse works but I need to use VS Code. Please help.
I'm trying to replicate in Intellij something easily done in Eclipse.
I want to run this Main class from the mainProject (nevermind the errors due to the use of fictional names):
Now, the problem is I need to be able to import a configuration folder from another project, in order to run the Main class. This is easy in Eclipse:
But I don't know how to do this is Intellij. Ideas?
This is actually why I despise the Eclipse workspace. It lets developers cheat and use another project's source as a dependency of another project. This is a problem because this isn't how it works outside of the IDE.
What you need to do is create a jar of classes you depend on, then include that jar as a dependency of the project that depends on them. If you use dependency management and have a local repository (like nexus or artifactory) you can publish your jar to your local repository and then in your other project just include it in your pom.xml if you are using Maven or build.gradle if you are using Gradle.
If you are instead including libraries in your source folder, copy the jar to your project, then right click on the jar in IntelliJ and select "Add as Library...". You can also add a dependency through File->Project Structure->Modules->Dependencies tab. Add as Library is a shortcut to adding a library here and the dependency shows up here if you use Add as Library.
IntelliJ does let you import a module from another project, but again this is cheating because it will just confuse you down the road because it will only work from within the IDE, not running as a standalone application. (File->Project Structure->Modules->Plus (+) Sign->Import Module)
Long title, but pretty much explains it. I've pulled a git repo (spring rest tutorial http://spring.io/guides/tutorials/rest/) which contains multiple standalone java projects each in separate folders. Each of these projects contains gradle build files as well as gradle itself (no need to install gradle), AND the necessary Spring jars (likely in the gradle-wrapper jar). I've created a java project in eclipse that mirrors one of the folders and the changes in eclipse are picked up no problem and it builds fine.
The problem I have is that the Spring dependencies aren't on the Eclipse build path, so I can't use all of the nice Eclipse features (function completion, auto imports, etc.). There's only one jar in each separate folder from the git repo and it's called gradle-wrapper.jar. My guess is that this contains all the Spring dependencies, as the project builds fine, assuming I've typed everything correctly and manually added correct import statements.
Is there a way to set this up so that I'm not getting all these ugly errors in the java project? I attempted to add the gradle jar to the java project build path, but this had no effect. I suppose one option would be to add the spring dependencies separately, but then the Spring on the build path wouldn't necessarily match the Spring dependencies used by gradle for the actual build.
Gradle projects don't package all the dependencies in the repository; one of the primary reasons to use Gradle or Maven is that they'll handle dependencies for you. You need the Gradle Eclipse plugin and to Import->Existing Gradle projects.
I am writing an application that uses GWT, some Spring MVC and Spring Security. Maven is be used to manage the dependencies and Eclipse is my IDE. I've created my application as follows:
webAppCreator -noant -maven -XnoEclipse -out MyApp com.example.MyApp
Then I've imported it into Eclipse as follows:
Imported as Maven project into Eclipse workspace.
In the project settings the "Use Google Web Toolkit" checkbox is ticked.
This project has a WAR directory" is checked. The WAR directory is set to src/main/webapp. The "Launch and deploy from this directory" is unchecked.
Then I test it's all OK:
Click run/debug, choose Web Application (the Google choice), and select target/www as the WAR directory.
So far, so good. Now I want to know how to control the development cycle. For example, I now want to add Spring to my application so I add this block to pom.xml and save it. The Maven Dependencies in Eclipse are expanded to show many new jars (Spring and its dependencies).
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
I also edit the web.xml to configure the Spring DispatcherServlet...
Once I've edited pom.xml and web.xml, clicking the debug/run icon on the toolbar will simply run from target/www again without any other steps taking place. This means the old web.xml is used, and target/www/WEB-INF/lib doesn't contain the Spring jars (and Spring's dependent jars). Do I need to drop to the command-line and issue Maven commands whenever particular changes are made?
The ideal answer will describe the development cycle for the above scenario.
My configuration:
GWT: 2.1.
Eclipse: Helios (3.6).
Maven: 2.2.1.
JRE/JDK: JDK 1.6.0.21.
Google Plugin for Eclipse 3.6 version 1.4.0.v201010280102.
Maven Integration for Eclipse (m2eclipse) version 0.10.2.20100623-1649 (this has been configured to point to Maven 2.2.1 environment and NOT to use the embedded Maven3 "instance").
I didn't understand you question completely but I use to create a separated gwt maven project and use apache web server to serve gwt files and then config my main webapp to load gwt files at client/browser. That save me from mixing gwt codes with my main webapp.
Edit regarding your comment:
Forget about gwt for start and read on ...
First you need to make sure that eclipse and maven are playing together correctly so that when you add dependency to you pom eclipse will recognize them too, and your eclipse project setup and structure match with maven.
Second you need to set up a web development configuration so that you can run/test your webapp. You can use maven jetty or tomcat plugin or eclipse tomcat server. IMHO using maven jetty plugin is better.
And Finally you need to package (using maven) and deploy (using maven or not) webapp to your deployment environment.
If you have been successful till now, then you can add gwt in using maven gwt plugin.
If you have installed eclipse maven plugin you can run maven commands from inside eclipse but it wouldn't hurt to run them from command prompt any way.