When I create a Spring MVC project in IntelliJIdea 2019.1, There is no sub-checkbox Spring MVC in spring checkbox.
Have you tested how your project has been created with just Spring checkbox marked? I mean, Spring MVC almost always appears in Spring projects, so It maybe is already added. Take a look at you config files (pom.xml or gradle.build) for something like this:
https://mvnrepository.com/artifact/org.springframework/spring-webmvc/5.1.6.RELEASE
I would recommend you to use this page for creating a Spring project:
https://start.spring.io/
Or instead, use Spring Tools 4: https://spring.io/tools
Both are official released by Pivotal and make some configurations for you in your pom.xml, if using Maven, or in your gradle.build, if using Gradle. Also, both provide the basic project structure.
If you further want to add some dependency, you can go to the repository (most times Maven repository, even if dealing with Gradle project) and then add to your pom.xml or gradle.build file. This one works for me 90% of the times: https://mvnrepository.com/
Please make sure the corresponding Spring MVC plug-in is enabled.
You should get this option after enabling the plug-in and restarting the IDE.
Note that it's a legacy way of creating Spring projects in IntelliJ IDEA and it will use rather old Spring version, it's recommended to use the Spring Initializr instead. Web dependency is for MVC projects.
Related
I have a spring web mvc project with gradle build tools. It is running perfectly fine. but I want to use swagger to generate open api documentation for it. So , I have used
implementation 'org.springdoc:springdoc-openapi-ui:1.5.2'.
But as soon i add this, it causing import problem.
import org.springframework.web.servlet.view.document.AbstractExcelView;
why including spring-doc open ui causing this? Without this dependency AbstractExcelView class is available.
When you include a new dependency in your project, it can sometimes conflict with other dependencies if they use different versions of the same library. In this case, it looks like the spring-doc-openapi-ui is using a different version of the Spring framework than the one that your project is using
I have a project based on Spring which is running successfully. Now I have created another project based on Jersey which I want to integrate with spring project in Jersey.
I have gone through internet and I added spring project in the build-path of the Jersey project.
Here the problem is whenever I run my Jersey project, it has to execute the Spring project first.
How to configure spring project in Jersey?
You should consider using a dependency management/build tool such as Maven or Gradle.
This way each of your projects will be a module, which can be referenced from the other project as a dependency. You can still use the first project alone and the two-dependent projects alone as wall. Then the tool lets you just simply package the resulting project in a artifact such as WAR with all the dependencies.
Here is a quick maven tutorial - Maven in 5 Minutes
It is a good idea to use such a tool in any case as it has many additional advantages:
Lets you manage also your third party dependencies without needing to manually download the libraries and add them to the classpath
It is much easier to use such a project in cases like continuous integration.
You can run all your tests automatically during the build process to make sure everything works
It resolves transitive dependencies (dependencies of your dependencies)
It builds resulting archive file for you
You can have multiple profiles for different environments
...
Make both of your projects modules of one Maven parent pom project. This way you can build them both at the same time.
Welcome,
I'm begginer in Spring (also in Spring Boot). I create four maven projects in Eclipse:
my-persistance
my-presentation
my-webservices
my-main
I have assumed every part of program will be store in one of these special projects. For example: html, jsp files will be store in "my-presentation", also like Spring #Controller files. Projects that aren't "my-main" should be build earlier and store in local maven repository [via 'mvn clean install']to add them to "my-main" war package.
I just read one Spring Boot guide:
http://spring.io/guides/gs/serving-web-content/
It works when all elements are in one project. I want move Web Controller to "my-presentation" and class Application to "my-main". Of course it isn't working. Could it be possible to do this?
You can check how to work with Maven and multiple module.
Basically, you create parent pom.xml, and in each submodule (my-persistance, my-presentation, etc.) you create submodule pom.xml, that refer to parent pom.xml.
I have a similar configuration in my example project, you can check pom.xml files
Is it good idea to create Java project with Spring persistence using Maven?
What maven archetype to use?
AppFuse is seemed to be freezed.
You an use Spring ROO to create a Spring project based on Maven.
The principle of a Maven archetype is to create a skeleton of an application based on some specificities (for example the usage of Spring in your case).
This skeleton will generate the root pom.xml, the basic directories structure (src/main/resources, src/main/java, and so on), as well as some other files, which are specific to the archetype used, such as the applicationContext.xml in the Spring case.
Of course, this is only a skeleton (which is however generally runnable to get some Hello World stuff), so you will have to adapt it to your precise requirements: change the pom.xml content (for example the versions of third libraries), add or remove some configuration files...
Maybe you can give a try to any AppFuse archetype (what do you mean by freezed by the way?), and then remove everything that is not needed in your case.
If you r using Netbeans 6.8 then follow below one
New Project->Maven->Maven PRoject->Default Archetype Catalog-> A simple J2EE Java application
Remove Other unused modules and modify it as per ur requirement...
So I downloaded a trial of idea ultimate, and I want to get spring mvc going with tomcat.
So I setup a new project, configured it to use sun jdk.
I chose a spring application, and it created and downloaded the following:
I don't see any spring-mvc libraries, are they included in there or do I have to do something about that?
Can someone outline what I have to do to get this to build like a spring mvc web application?
I find that the best way to start a new IDEA project is to use the Maven. This allows you to easily build your project without launching the IDE, automatically maintaining all libraries for you.
"Create project from scratch", then select "Maven module" in the next screen. Click on "Create from archetype" and select the "maven-archetype-webapp". This will give you a basic Maven layout which builds a simple WAR file.
Now to add the Spring libraries, open the Maven build file - pom.xml - and insert a new dependency on the Spring MVC framework:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.0.RELEASE</version>
</dependency>
From here, you can follow the Spring MVC reference documentation - add the Dispatcher Servlet and Context Listener to web.xml, a Spring XML context and so on.
Something else you might find useful is the Maven Jetty plugin. Once configured, you can run your app by simply typing "mvn jetty:run" at the command prompt (or launching it from within the IDE). Maven will fetch all that's required and deploy the app for you, no need for an external app server setup for quick testing.
I'm not sure if your setup would be identical to mine, but when I downloaded spring-framework-2.5.6 there were jar files named spring-web.jar, spring-webmvc.jar, etc. in the \dist\modules subfolders. The tutorial indicated at least spring-webmvc.jar should be in your WEB-INF/lib folder.
This tutorial optionally used eclipse, but might be helpful anyways, especially getting started:
http://static.springsource.org/docs/Spring-MVC-step-by-step/
I think there are specific JARs for the Spring MVC stuff. Basically when you download the latest Spring Framework and you extract the zip you need to go to the dist folder and add the org.springframework.web.jar and org.springframework.web.servlet.jar/org.springframework.portlet.jar to your project. I'm pretty sure that the servlet/portlet jars will have your MVC specific classes.