I am trying a create JEE spring web project (+spring security, mvc, web flow) and it will be a maven project with IntelliJ IDE.
I tried :
1) Create Project as "Spring",
2) Additional Libraries and frameworks : Spring, Spring MVC, Spring Security, Spring Web Flow. Web Application, Application Server, Hibernate.
And click on Finish button.
3) After project created, right clicked and "Add frameworks support" and selected maven.
I have three questions :
1) Is this a right approach to create a spring web maven project with IntelliJ?
2) Project has a lib folder that has spring, hibernate jars etc. They are not included in pom.xml file as dependency. How can i make them as they defined in pom.xml file so these jars will be in "External Libraries" folder?
3) When i didn't select "Application Server" while creating a new project, I cannot add later, when the project is created using "Add frameworks support". Why?
Thanks in advance.
Is this a right approach to create a spring web maven project with
IntelliJ?
No, create a Maven (or Gradle) project form starting point and then add dependencies through Maven (or Gradle) dependency management system. Generally, managing dependencies through lib folders or System Wide Dependencies are NOT good ideas. Read more on
Project has a lib folder that has spring, hibernate jars etc. They are
not included in pom.xml file as dependency. How can i make them as
they defined in pom.xml file so these jars will be in "External
Libraries" folder?
Delete all jar files and replace them with dependency section of pom.xml. You should find groupId, artifactId and version coordiantes of each one. For example, for spring-core module, you should add this to your <dependencies></dependencies> section:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.0.RELEASE</version>
</dependency
When i didn't select "Application Server" while creating a new
project, I cannot add later, when the project is created using "Add
frameworks support". Why?
After creating project, you can add Application Servers or Servlet Containers through Run > Edit Configuration settings.
Related
I have an existing project. I need to make it a Spring boot based project and I am using IntelliJ CE.
What would be correct procedure for doing it?
Edit:
Project has no initial structure. It is a totally empty project. So no existing modules etc.
Spring Boot is an Ultimate feature, so first you would need to try/buy the IntelliJ IDEA Ultimate.
From there, you can add Spring support to existing project modules or use the Spring Initializr wizard to select the necessary configuration when creating a new project or module.
In your maven pom.xml or build.gradle file, I would add the spring boot starter dependency:
spring-boot-starter (the group id is org.springframework.boot)
If the application is a web application, I would also add the web starter spring-boot-starter-web also with the same group id (org.springframework.boot)
For convenient features, applying the spring boot plugin would help in creating a runnable jar with all required dependencies bundled called a fat jar.
A great tool I use is the spring boot project generator. It allows you to configure the modules you want and create a project template.
Spring Boot requires IntelliJ IDEA Ultimate. If you want to use IntelliJ CE, please create a project using Spring Initilizer then import the same to your IntelliJ CE (File -> Open -> Choose the project root folder). After you import the project, wait for some time so that IntelliJ can download the dependency and build your project. You can check from (Build -> Build your project). Then find the main class of spring boot and run it using the green play button
Hey I am writting a project which includes 2 other maven project:
JPA with EJB project (DAO layer) packaging .jar
Rest Services Project packaging .war
I found help with setting dependency with eclipse. In my war project I've added local project with DAOs. Compiling, building(mvn clean install on two pom.xml) went succesfull. But I can't deploy it on wildfly server. I get NoClassDef of class from my jar package.
On the other hand I saw a lot of projects with DAO packing in jar. But there are EJB3 annotations. Will they work with JEE Server in that configuration?(They don't need web.xml so maybe it is correct). Which scope i have to set of my dependent DAO project? If i have NoClassDef error it seems there is no compiled classes at runtime, or there is 2 or more definitions of classes from this package. I've tried few configurations, but I can't get solution.
Could someone write best practice to setting maven projects? For example
DAO layer type: jar
Rest Services layer type: war, dependence: DAO { scope: default, type:jar}
I think a good practice would be to define a project parent (Parent POM), which must define the module involved:
<modules>
<module>application-dao</module>
<module>application-rest</module>
</modules>
and define as a dependency, your application ".jar"
<dependency>
<groupId>com.test</groupId>
<artifactId>application-dao</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
A recommendation you could add an extra layer of management, then you would
application-dao
application-core
application-rest
I am using Spring Tool Suite (STS) for my Spring boot application development.
I am using the Spring Started Project option to select the component required for my applications. For example: if I want to develop web application, I will select the "web" check box and spring io initailzier will download all the required jars in the classpath with help of maven.
Suppose, after the project creation for WEB, If I want to add some other components in my existing web project like using Eureka, Hystrix, the required jars are not automatically setup in the classpath and couldn't use the annotation like #EnableEurekaClient as it throws error as jar is missing.
I have manually updated the pom.xml to include the Eureka starter/client/server dependency and trying to update the project (Project >> Maven >> Update Project), so that required jars will be in classpath. But it is not happening.
Any advise on it..thanks.
I'm starting to develop a Spring-MVC Portlet project. I did all the configuration needed in portlet.xml and web.xml but still a little bit confused about the Spring dependencies that have been declared in liferay-plugin-package.properties. In fact, should I add the required dependencies in this file and declare them as provided in the project pom.xml?
I use Maven as the build and dependency management tool and all examples I've found are based on the ANT project.
How does Liferay is processes the dependencies declared in liferay-plugin-package.properties ?
Besides, a maven compile fails since it does not find Spring MVC libraries required for the Spring MVC portlet project. What do you think is missing (or) incorrect in the configuration to create Spring MVC portlet ?
thanks in advance
The easiest way to go about this is to use the Maven Archetype that's been provided by liferay.
The Maven dependency is:
<dependency>
<groupId>com.liferay.maven.archetypes</groupId>
<artifactId>liferay-portlet-spring-mvc-archetype</artifactId>
<version>6.2.10.15</version>
Install this archetype in your local repository and then create a Maven project from this archetype.
This will have all the prerequisites needed for your project.
It is not necessarily to put any dependencies into liferay-plugin-package.properties file. All you need for your Spring MVC Portlet project should be presented in the project pom.xml file.
All dependencies are accessible from maven repo, e.g. http://mvnrepository.com/artifact/org.springframework/spring-webmvc-portlet
I have 3 maven projects:
1 - common pojos project
2 - web project
3 - java client project
web and java project uses same pojos from common project, have dependency on 1 project
I added to web build path common pojos project,
but when I deploy web project to server, no pojo classes exceptions....
My question is how can I configure it to get my pojos classes deployed with all web project ?
(it will be fantastic, If you have some online examples for this)
Tnx.
If all your 3 project are maven projects and the dependencies are set right then maven will automatically package all the dependencies into the war.
commons pojos is a jar project
web project is a war project which depends on commons pojos project. Unless the dependency scope is not provided the jar will be packaged in the war.
You can verify the same by opening the war file as see if the commons pojos jar is present and the jar has the required classes.