Last active
December 19, 2015 04:48
-
-
Save kongliangzhong/5899183 to your computer and use it in GitHub Desktop.
J2EE stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
J2EE STUFF | |
=== JMX === | |
=========== | |
=== MAVEN === | |
1. use plugin short name: | |
add following content in ~/.m2/settings.xml: | |
<profile> | |
<pluginGroups> | |
<pluginGroup>org.mortbay.jetty</pluginGroup> | |
</pluginGroups> | |
</profile> | |
2. generate project based on sample project: | |
cmd: mvn archetype:generate | |
then add filter strings. | |
3. run main class use exec plugin: | |
mvn exec:java -Dexec.mainClass="cn.klzhong.App" [-Dexec.args="arg1" ...] | |
4. download sources of a specific dependency: | |
mvn dependency:sources -DincludeGroupIds=javax.validation | |
5. skip test: mvn isntall -Dmaven.test.skip=true | |
6: deploy jar to nexus use maven command: e.g. | |
mvn deploy:deploy-file -DgroupId=com.lianlian.platform | |
-DartifactId=serviceEncryptor | |
-Dversion=1.0 | |
-Dpackaging=jar | |
-Dfile=./serviceEncryptor-1.0.jar | |
-DrepositoryId=releases | |
-Durl=http://192.168.88.8:8081/nexus/content/repositories/releases/ | |
7: run single test(test method): | |
mvn -Dtest=TestCircle#xyz test //where TestCircle is the test class name and xyz is the test method | |
------ maven errors: ------ | |
1) can not generate class file in target dir: | |
recheck package declare in your source files. | |
2) annotation error: make sure you have imported the annotation type. | |
3) Failed to execute goal on project booking-mvc: Could not resolve dependencies for project org.springframework.webflow.samples:booking-mvc:war:1.0.0.BUILD-SNAPSHOT: Failure to find org.springframework.webflow:spring-js-resources:jar:2.4.2.BUILD-20150605.020814-7 in http://192.168.88.8:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of public has elapsed or updates are forced: | |
use -U to force update: e.g. mvn -U tomcat7:run | |
============= | |
=== GRADLE === | |
1. exclude jars in dependency: | |
configurations { | |
runtime.exclude group: 'com.sun.jdmk', module: 'jmxtools' | |
runtime.exclude group: 'com.sum.jmx', module: 'jmxri' | |
} | |
2. build with error: invalid source release: 1.7 | |
turns out i set a JAVA_HOME enviroment variable to a JDK1.6 in .bashrc, | |
so my gradle1.8 use its jvm, then it can not support java 1.7. | |
delete JAVA_HOME env variable, and everything goes fine. | |
3. run a single unit test: | |
gradle -Dtest.single=TEST_CLASS_NAME test | |
4. gradle help system: | |
1) command help: gradle --help | |
2) help task: gradle help --task taskName. e.g. gradle help --task help | |
3) list tasks: gradle tasks. | |
5. show dependencies for specific scope: | |
gradle dependencies --configure scopeName | |
hint: use gradle help --task dependencies for task infomation. | |
6. skip test: -x test | |
e.g. gradle build -x test | |
============== | |
==== spring ==== | |
--- spring mvc | |
1) If you use Spring 3, you can distinguish between controller methods using params at tribute: | |
<input type = "submit" name = "next" value = "Next" /> | |
<input type = "submit" name = "back" value = "Back" /> | |
@RequestMapping(..., params = "next") | |
public ModelAndView next(...) { ... } | |
@RequestMapping(..., params = "back") | |
public ModelAndView back(...) { ... } | |
================ | |
==== JBOSS ==== | |
### install jboss-7.1 on ubuntu 13.04 ### | |
1) download jboss: | |
wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip | |
2) unzip: | |
sudo unzip jboss-as-7.1.1.Final.zip -d /usr/share/ | |
3) for security reasons, create a new user to run jboss: | |
sudo adduser jboss | |
4) sudo chown -fR jboss.jboss /usr/share/jboss-as-7.1.1.Final/ | |
5) su - jboss | |
6) add management user: | |
cd /usr/share/jboss-as-7.1.1.Final/bin | |
./add-user.sh | |
=============== | |
==== TOMCAT ==== | |
1. enable ssl for tomcat: | |
1) create keystore file: keytool -genkey -alias tomcat -keyalg RSA | |
2) Uncomment the "SSL HTTP/1.1 Connector" entry in $CATALINA_BASE/conf/server.xml | |
2. Installing a Certificate from a Certificate Authority: | |
1) Create a local Certificate Signing Request (CSR): | |
a) Create a local self-signed Certificate: | |
keytool -genkey -alias tomcat -keyalg RSA -keystore <your_keystore_filename> | |
b) The CSR is then created with: | |
keytool -certreq -keyalg RSA -alias tomcat -file certreq.csr -keystore <your_keystore_filename> | |
2) Importing the Certificate: | |
3. modify conf/server.xml: | |
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" | |
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" | |
clientAuth="false" sslProtocol="TLS" keystoreFile="/Users/klzhong/.keystore" | |
keystorePass="changeit" truststoreFile="/Users/klzhong/security/cacerts" /> | |
================ | |
==== CAS SSO ==== | |
1. Generating a certificate: | |
1) keytool -delete -alias tomcat -keypass changeit | |
2) keytool -genkey -alias tomcat -keypass changeit -keyalg RSA | |
3) keytool -export -alias tomcat -keypass changeit -file server.crt | |
4) keytool -import -file server.crt -keypass changeit -keystore $JAVA_HOME/jre/lib/security/cacerts | |
-- keytool error: java.lang.Exception: Certificate not imported, alias <mykey> already exists: | |
-- delete mykey in cacerts: | |
keytool -delete -alias mykey -keystore /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/security/cacerts | |
================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment