How do I use Notepad++ (or other) with msysgit?

git config –global core.editor “‘C:/Program Files/Notepad++/notepad++.exe’ -multiInst -notabbar -nosession -noPlugin” Or, for 64-bit Windows and a 32-bit install of Notepad++: git config –global core.editor “‘C:/Program Files (x86)/Notepad++/notepad++.exe’ -multiInst -notabbar -nosession -noPlugin” Or, the following can be issued on the command line on either 32-bit or 64-bit Windows. It will pull the location of notepad++.exe from … Read more

How to set the java.library.path from Eclipse

Don’t mess with the library path! Eclipse builds it itself! Instead, go into the library settings for your projects and, for each jar/etc that requires a native library, expand it in the Libraries tab. In the tree view there, each library has items for source/javadoc and native library locations. Specifically: select Project, right click -> … Read more

Where to place AutoMapper.CreateMaps?

Doesn’t matter, as long as it’s a static class. It’s all about convention. Our convention is that each “layer” (web, services, data) has a single file called AutoMapperXConfiguration.cs, with a single method called Configure(), where X is the layer. The Configure() method then calls private methods for each area. Here’s an example of our web … Read more

Is the buildSessionFactory() Configuration method deprecated in Hibernate?

Yes it is deprecated. Replace your SessionFactory with the following: In Hibernate 4.0, 4.1, 4.2 private static SessionFactory sessionFactory; private static ServiceRegistry serviceRegistry; public static SessionFactory createSessionFactory() { Configuration configuration = new Configuration(); configuration.configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings( configuration.getProperties()). buildServiceRegistry(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; } UPDATE: In Hibernate 4.3 ServiceRegistryBuilder is deprecated. Use … Read more

Where to place and how to read configuration resource files in servlet based application?

It’s your choice. There are basically three ways in a Java web application archive (WAR): 1. Put it in classpath So that you can load it by ClassLoader#getResourceAsStream() with a classpath-relative path: ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream input = classLoader.getResourceAsStream(“foo.properties”); // … Properties properties = new Properties(); properties.load(input); Here foo.properties is supposed to be placed … Read more

Getting Spring Application Context

If the object that needs access to the container is a bean in the container, just implement the BeanFactoryAware or ApplicationContextAware interfaces. If an object outside the container needs access to the container, I’ve used a standard GoF singleton pattern for the spring container. That way, you only have one singleton in your application, the … Read more

.NET Core Unit Testing – Mock IOptions

You need to manually create and populate an IOptions<SampleOptions> object. You can do so via the Microsoft.Extensions.Options.Options helper class. For example: IOptions<SampleOptions> someOptions = Options.Create<SampleOptions>(new SampleOptions()); You can simplify that a bit to: var someOptions = Options.Create(new SampleOptions()); Obviously this isn’t very useful as is. You’ll need to actually create and populate a SampleOptions object … Read more