Add external jar in pom.xml

Option 1: Copy jar in local repo

Under dependencies section, add following block.
<dependency>

<!– groupId – 0 level directory name = you may give any name –>
<groupId>custom</groupId>

<!– artifactId- 1 level sub directory name =  should be name of the jar without version number –>
<artifactId>simplecaptcha</artifactId>

<!– version- 2 level sub directory name = jar version mentioned in jar file name –>

<version>1.2.1</version>

</dependency>

Under C:\Users\<username>\.m2\repository

  • Create directory with name as value you have given in  <groupId></groupId>
    • Go into this directory
    • Create directory with name as value you have given in  <artifactId></artifactId>
      • Go into this directory
      • Create directory with name as value you have given in  <version></version>
        • Copy your jar here

Example:

My file is stored here:

C:\Users\<username>\.m2\repository\custom\simplecaptcha\1.2.1\simplecaptcha-1.2.1.jar

 

 

Option 2: Use system scope

Example:

<!– Hibernate –>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
<scope>system</scope>
<systemPath>G:/Setups/hibernate-release-4.3.6.Final/hibernate-release-4.3.6.Final/lib/required/hibernate-core-4.3.6.Final.jar</systemPath>
</dependency>

 

Fix STS VMware vFabric start issue.

Issue:

starting vmware vfabric tc server developer edition* encountered a problem

Resolution-1:

  • Close all Java related processed, programs, servers, IDEs.
  • Go to task manager, kill java process.
  • STSIssue-TaskManagerRestart everything and test again.

Resolution-2:

  • If Resolution-1 one does nit work, i am assuming Server instance may have been corrupted.
  • Close all Java related processed, programs, servers, IDEs.
  • Go to task manager, kill java process.
  • Find server location.

STS-FindLocation

  • Navigate two directories back to reach following.

           ..spring-tool-suite-3.6.0\sts-bundle\vfabric-tc-server-developer-2.9.6.RELEASE

  • Take backup of “base-instance” directory by renaming it.
  • Create new “base-instance” by following below steps.
  • Start command prompt in admin mode.
  • Follow guide.

Internationalization Spring 3.1.1

servlet-context.xml is src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml

xmlns:mvc = “http://www.springframework.org/schema/mvc”

servlet-context.xml is src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml

<!– i18n –>
<bean id=”messageSource”
class=”org.springframework.context.support.ReloadableResourceBundleMessageSource”>

<!– if you are keeping files in src/main provide value: “classpath:messages” –>

<property name=”basename” value=”/resources/i18n/messages” />
<property name=”defaultEncoding” value=”UTF-8″/>
</bean>

<mvc:interceptors>
<bean class=”org.springframework.web.servlet.i18n.LocaleChangeInterceptor”>
<property name=”paramName” value=”lang” />
</bean>
</mvc:interceptors>

<bean id=”localeResolver”
class=”org.springframework.web.servlet.i18n.CookieLocaleResolver”>
<property name=”defaultLocale” value=”fr”/>
</bean>

Message files

i18n-1

Working:

i18n-2

i18n-e

 

messages_en.properties:

home.button.download = Download

messages_es.properties:

home.button.download = Descargar

Note: Set property file encoding as “UTF-8”

JSP:

<spring:message code=”home.button.download” text=”” />

Array can be created like this which can be used in JS later:

<script type=”text/javascript”>
var i18n_js = new Array();
i18n_js[‘home.button.download’] = “<spring:message code=’home.button.download’ javaScriptEscape=’true’ />”;
i18n_js[‘home.app.title’] = “<spring:message code=’home.app.title’ javaScriptEscape=’true’ />”;
i18n_js[‘home.app.sub.title’] = “<spring:message code=’home.app.sub.title’ javaScriptEscape=’true’ />”;
</script>