문제

I am a newbie to J2EE and I am not able to understand the directory structure created on building the java web project. After bit of googling i understood what we store in WEB-INF but
1)i am not able to understand that what we store in META-INF ?
2)how target folder get created?
3)where we mention that what all files should be placed in target folder?

I am using Maven to build the project which is a spring-hibernate based project.

thanks in advance

도움이 되었습니까?

해결책

1) What's the purpose of META-INF?

2) Maven creates the target folder for you. It's where all of the Maven plugins dump their work by default.

3) Maven has mechanisms for excluding files from it.

The key to understanding Maven is that Maven works on conventions. That means that Maven will do a lot of things really well with almost no effort on your part if you structure your project according to Maven's expectations. For example, this is how you differentiate between Java classes and resources in the source directory:

src/main/java/com/mycompany/MyObj.java  
src/main/resources/my/company/spring.context.xml  
src/test/java/com/mycompany/MyObjTest.java  
src/test/resources/my/company/spring.context.xml

When you run mvn test it will compile all of that, move it appropriately over to the target folder, load the JUnit runner and give you a classpath that will let Spring have easy access to the spring context under the test folder. It'll run the tests and drop the reports under target.

Maven is not like Ant. In Ant, you have to tell it everything. Maven works on the opposite end in that it assumes everything by default until you tell it otherwise.

다른 팁

This is a common problem because java has grown so big. Its often hard to tell where one technology ends and another begins. You need to familiarize yourself with the documentation for all the various components you are using.

For instance, if you have a 'target' folder then I assume you are using maven. Maven is a java utility used for dependency management. When you 'mavenize' a project, you agree to adhere to a bunch of standards and maven in turn does a lot of the grunt work for you(compiling code, finding dependent libraries, and running tests). Part of what maven does is create standard maven directories in this case 'target'

more maven info - http://maven.apache.org/

As for META-INF this is part of the Java EE spec. It does have a purpose concerning packaging and deployment, but you'll generally not finding yourself using it very often. Its generally the same principle as maven. You adhere to the Java EE standard and the Java EE compliant tools do most of the work for you.

For more info look at this link - http://java.sun.com/blueprints/guidelines/designing_enterprise_applications/packaging_deployment/index.html

In general to understand these you should check out some tutorials on Java EE and refer to your container's examples and documentation.

1) What is the purpose of the META-INF
2-3)Target folder creates Macven, it manages all dependensies, etc: one, two

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top