Reputation: 337
I'm attempting my first Strusts2 project(Windows, 64x, ItelliJ).
I'm following the tutorial found here:
This a picture of my file structure, web.xml, & struts.xml:
http://screencast.com/t/0F5LN2nR4Dt
This tutorial uses Maven to manage artifacts and build the web application archive (war) file. I currently learning Maven as well, used a few times, but still pretty new.
When I built the project in IntelliJ, File > New Project > Java > Web Application > Struts 2. This created the setup you will see in the picture above. It appears to have added all needed files and structure to the project, with one exception, Step 4 - Add Logging(log4j). As far as I can tell, the IntelliJ Struts2 setup pulled in most/all of the needed dependencies, except for:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
I have all the needed files, except for log4j.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c.%M:%L - %m%n"/>
</layout>
</appender>
<!-- specify the logging level for loggers from other libraries -->
<logger name="com.opensymphony">
<level value="DEBUG" />
</logger>
<logger name="org.apache.struts2">
<level value="DEBUG" />
</logger>
<!-- for all other loggers log only info and above log messages -->
<root>
<priority value="INFO"/>
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
The above tutorial states, "Setup a log4j.xml configuration in the src/main/resources folder."
So I guess my questions are:
1) Do I need to/should I add Maven to this project? If so how do I go about this?
2) How should I go about bring in the log4j.jar(s), where should I place them?
3) Where in my file structure would you recommend that create my resource folder?
4) Anything else you think might help someone learning Struts2.
Upvotes: 2
Views: 6459
Reputation: 4480
1) Yes, you should probably use either Maven or Gradle to manage your dependencies (it makes it way easier).
2) If you decide to use Maven, all you gotta do is put the pom.xml that the guide you are using has in the root directory of your project. Here's the pom.
3) Typically the resources folder goes in src/main (src/main/resources).
4) Mkyong.com is a pretty good learning resource. Good luck!
Upvotes: 2