I tried to make project by selecting Archtype Web Application from Eclipse create new maven project. But when I created a new java Class to project sources folder, it didn't contain packacge name in package and source folder was included in class path. So is there something wrong with my setup or why doesn't Eclipse add automatically package to newly created Class?
To run the maven project, select it and go to “Run As > Java Application”. In the next window, select the main class to execute. In this case, select the App class and click on the Ok button. You will see the “Hello World” output in the Console window.
This is what I do:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.6.SEC01</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>2.5.6.SEC01</version> </dependency>
The easiest way would to use Spring Tool Suite as suggested by @Stephen which is a bundled version of Eclipse for Spring development. It packages plugins such as Spring IDE, M2Eclipse, etc and offers custom Project templates for Spring projects (via New > Project...). This gives you a fully configured project.
The Maven webapp archetype allows to obtain a similar result but involves more manual steps: you'll have to add src/main/java
, create the base package and add Spring dependencies manually (so no, there is nothing particularly wrong with you setup).
In Spring Tool Suite (STS) you can try this. Create a Maven project. You can add pom.xml dependencies to whatever Spring libs you may need. For example:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.5.RELEASE</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
After the project is created, right click it in the Package Explorer and choose Spring Tools -> Add Spring Project Nature. Et voila, you should have a Maven/Spring project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With