How to change the "Dynamic Web Project" source and output folders by default in Eclipse?

How to change the default values ​​of “source folders on the build path” and “default output folder” in the “Dynamic Web Project” wizard in Eclipse is probably the same as what we do for the “Java Project” in

Windows> Preferences> Java> Build Path

Purpose: every time I create a new Dynamic Web Project, the wizard should show the default source and output folders. Since this option is available for a Java project, I believe that for web projects there should also be something similar, but I can not find it. BTW I tried to change the default Java settings, but this does not affect dynamic web projects.

+4
source share
2 answers

Can you add web features to an existing Java project?

Also, this is how to convert a Java project by editing the .project file (different from the way I remember how it was done in Eclipse). This may give some insight into how to modify the .project file.

docs seem to indicate that JavaSource is a property that dictates your Java source files for dynamic web projects.

JavaSource Contains the Java project source code for classes, beans, and servlets. When these resources are added to the web project, they are automatically compiled, and the generated files are added to the WEB-INF / classes directory. The contents of the source directory are not packaged into WAR files unless specified when the WAR file is created. Note. Although the default name for the folder is JavaSources, you can change the name by right-clicking on the name in Project Explorer and clicking Refactor> Rename.

In addition, I think, since Dynamic Web Project must adhere to J2EE standards, you cannot change the path to the output folder in your project. However, you can rename it if you want.

WebContent folder Required location of all web resources, including HTML, JSP, image files, etc. If the files do not fit in this directory (or in the subdirectory structure in this directory), the files will not be available if the application is running on the server. The web content folder is the contents of the WAR file that will be deployed to the server. Any files that are not in the web content folder are considered development-time resources (for example, .java files, .sql files and .mif files) and are not deployed when testing or publishing a project. Note. Although the default name for the folder is WebContent, you can change the name in Project Explorer by right-clicking the folder and selecting "RefactorRename" or on the web page of the Project Properties dialog box. In a dynamic web project, changing the folder name will update the Java build output directory.

+3
source

It is very simple.

1. Create a text file named "org.eclipse.wst.web.prefs", add the following configuration to it:

# content directory, change the default name "WebContent" to "Webroot"

WebContent = Webroot

# draw the default web project output from% proj% \ bin% Webroot% \ WEB-INF \ classes

useSingleRootStructure = true

2. Move it to% workspace% \. metadata \ .plugins \ org.eclipse.core.runtime \ .settings.

3. Launch the eclipse.

0
source

Source: https://habr.com/ru/post/1333066/


All Articles