Build multiple-module maven project in Eclipse

Reference:
http://www.sonatype.com/books/m2eclipse-book/reference/
http://maven.apache.org/plugins/maven-eclipse-plugin/reactor.html
http://yyhh.org/blog/2008/02/create-multiple-modules-maven-project-eclipse

My summary:

  • Create the maven project by run the following maven command in *nix shell or windows cmd under the Eclipse workspace:
    mvn archetype:create -DgroupId=testgroup -DartifactId=test
  • Modify the project. Delete the src/ subfolder and then edit the pom.xml to make sure the packaging element in it is set to “pom” instead of the original “jar”.
  • Create module. First enter the project folder (cd test); and then run the maven command:
    mvn archetype:create -DgroupId=testgroup.module1 -DartifactId=module1
  • Create a new project in Eclipse. Two methods can be used depending on the version of m2eclipse:
    • For new version of m2eclipse. Click the Eclipse menu: File -> Import -> Maven -> Existing Maven Projects
    • For old version of m2eclipse. Run the command:
      mvn eclipse:eclipse
      and then click the Eclipse menu: File -> New -> Project -> General -> Project, and then click Next, and put the Project name as “test”. Click Finish.

Secure ssh host

Modify the /etc/ssh/sshd_config file and turn on the following section (remove the # char)

#LoginGraceTime 2m
#PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6

/etc/init.d/sshd restart

Reset mysql root password under Windows or *nix

Windows (mainly copied from Geekpedia)

1. Stop your MySQL server completely. This can be done by accessing the Services window inside Windows XP and Windows Server 2003, where you can stop the MySQL service.

2. Open your MS-DOS command prompt using “cmd” inside the Run window. Inside it navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

3. Execute the following command in the command prompt: mysqld.exe -u root ––skip-grant-tables

4. Leave the current MS-DOS command prompt as it is, and open a new MS-DOS command prompt window.

5. Navigate to your MySQL bin folder, such as C:\MySQL\bin using the cd command.

6. Enter “mysql” and press enter.

7. You should now have the MySQL command prompt working. Type “use mysql;” so that we switch to the “mysql” database.

8. Execute the following command to update the password:

UPDATE user SET Password = PASSWORD(‘NEW_PASSWORD’) WHERE User = ‘root’;

However, you can now run any SQL command that you wish.

After you are finished close the first command prompt and type “exit;” in the second command prompt windows to disconnect successfully. You can now start the MySQL service.

Please note that the 8 step process above can differ depending on the MySQL version you are using, how you configured your server, etc. However, many times you can still easily work around a problem that you experience in any of the steps.

Linux/Unix (mainly copied from ciberciti)

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop

Output:

Stopping MySQL database server: mysqld.
Step # 2: Start to MySQL server w/o password:

# mysqld_safe ––skip-grant-tables &

Output:

[1] 5988
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6025]: started
Step # 3: Connect to mysql server using mysql client:

# mysql -u root

Output:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>
Step # 4: Setup new MySQL root user password

mysql> use mysql;
mysql> update user set password=PASSWORD(“NEW-ROOT-PASSWORD”) where User=’root’;
mysql> flush privileges;
mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop

Output:

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended

[1]+ Done mysqld_safe –skip-grant-tables
Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start
# mysql -u root -p