How to use Spring 5.0 in NetBeans 8.2? - spring-mvc

When I create a Java Web project in NetBeans and select a Framework, in this case Spring Web MVC, only two options appear:
Version 4.0.1
Version 3.2.7

You can do this in Netbeans:
Download the Spring Framework you need from here
Extract the contents of the archive and copy the contents of the lib directory to your netbeans location e.g /home/stanley/netbeans-8.2/java/modules/ext/spring-(version) e.g 5.1.4
On your netbeans go to Tools > Libraries > New Library
Name your Library as Spring Framework (version) e.g 5.1.4 and add all the jars from the location in 2 above.
Restart your netbeans application.
You should have the new Framework as shown in the diagram below:

TL;DR
The easiest way to create a new spring project is using Spring Initializr. All you need to do is fill in the form, download the project, unzip it and open in NetBeans.
Explanation
Regardless of a language and IDE, it is usually good idea to create a new project based on a standard build-tool for the language's ecosystem and avoid creating an IDE-specific project. That makes it easier to share the project with people who use a different IDE and switch your IDE in the middle of the project.
There are several build-tools for Java ecosystem but I'd suggest to pay attention to two of them: Maven and Gradle. Those are most widespread and supported by IDEs.
NetBeans supports Maven out of box. It supports Gradle too but in 8.2 you are supposed to install a support plugin for Gradle (from Tools -> Plugins menu).
You can generate a new Maven or Gradle project using NetBeans. Select corresponding menu item when selecting the type of the project.
Then you will have to add the dependencies of the project to its descriptor (pom.xml for Maven or build.gradle for Gradle). See the documentation for the build-tool of your choice to understand how exactly to do that.
Spring provides Spring Initializr service to generate a new project based on spring's libraries. It is the easiest way for a quick start.

Since you are using Netbeans and it supports Maven out of the box, you can get an existing Maven archetype to setup a basic Spring application for you to start from.
Although there isn't any official archetype, there are a lot of really nice 3rd party ones like https://github.com/kolorobot/spring-mvc-quickstart-archetype
The steps to start a new project are quite fast and straight forward (Netbeans 11)
File -> New Project -> Java with Maven -> Project from archetype
In the search filter enter spring-mvc-quickstart-archetype, enter your project details and click Finish

Related

Creating an MSI installer for a C# SCD Deployment (Visual Studio 2019)

I have a .Net Core 3.1 application that I'd like to deploy as a Self Contained (SCD) Deployment using an MSI Installer in Visual Studio 2019...
I have published the project as an SCD Deployment and I can run this on the target machine just fine
However, I've been asked by IT support to provide an MSI installer for the application as .MSI files work well with some of the admin/control applications they have.
So I created a setup project in my solution and selected 'Publish Items' as the Project Output of the setup project and rebuilt it...
The installer seems to run just fine on the target machine but when we try to run the installed application it says that .Net Core is required ...It's as if the installer has ignored the Self Contained aspect and just installed as a regular Framework Dependent Deployment
Is there a way to create an installer that installs an SCD deployment? Have I made a mistake in my thinking?
Many Thanks in advance,
Andy
The VS Setup Project template is quite old. Most likely it was not updated to be "aware" of the SCD support so it resorts to extracting the classic output binaries from your project.
There are other free tools that you can use to create an MSI from VS, which give you more options to customize and correctly configure the package.
If you have time and want to learn a new skill, try WiX Toolset. It is very powerful but you will need some time to get started.
If you wanted to get it done quickly and avoid the hassle, use the free VS Extension from Advanced Installer. Its GUI allows you to easily create your setup package and it has native support for .NET Core packaging too. If you follow the steps from the linked tutorial it should create a working package for your application.
Disclaimer: I work on the team building Advanced Installer.

what is the best way to find out if a nuget package is compatible with .net core without nuget.org?

I know nuget.org does not have this functionality yet, but I have been searching for release notes on the nuget package developer websites, and this is taking longer than expected, since I have a lot of nuget packages installed on my .net framework project.
Is there a better way to do this? maybe someone has already done it and posted a list somewhere?
thanks in advance
If you change the 'n' in the nuget URL to an 'f', so it becomes fuget, you'll get a list of which frameworks the package targets. If you see it targets a netstandard version then it will work with .NET Core.
If your project is using an "old" style csproj with packages.config, the first step is to migrate to using PackageReference instead. Here's some docs. As the docs say, there are some differences between how packages.config and PackageReference works. If you're affected, you're blocked until you can make your project work with PackageReference.
If your project is using an "old" style csproj with PackageReference (for example you did the migration above), then migrate to SDK-based csproj so you can build with the dotnet CLI. Here's a blog post with details how to do it.. Note you you can keep using the Windows .NET Framework with SDK csproj. Although SDK-based csproj came out at the same time as .NET Core, it's not necessary to use .NET Core with the new project style. If your project is a class library or console app, you're definitely fine, otherwise you need to research to find out if the project type is compatible with SDK projects or not.
Once you have your .NET Framework project working with SDK projects, either change the TargetFramework to netcoreapp or netstandard, or you can multi-target your project by changing TargetFramework to TargetFrameworks, and use a semi-colon separated list of TFMs you want to target. For example <TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>. Then simply run dotnet restore and if any of the packages you use is not compatible with .NET Core, restore will fail, and you simply revert to target only .NET Framework.
In summary, once your project uses SDK-based csproj, it takes 10 seconds to test if your dependencies are compatible with .NET Standard/.NET Core. If your project is not yet using SDK-based csproj, you undo your change to the TargetFramework(s) line in your csproj and continue with your life until the next time you test again. If you're not already on SDK-based csproj and there's nothing blocking you from doing so, then doing the upgrade is low risk and bring some benefits, such as fewer merge conflicts on the file, much easier to create nupkgs for any packages you maintain, and being able to test against .NET Core compatibility in seconds.
Alternative: If you're unable or unwilling to migrate to SDK-based projects and you want to check if your dependencies are compatible, then use dotnet new classlib to create a new .NET Core project, add package references to the same packages that your existing project uses, then try to restore. If you have a big solution with lots of projects and/or references, just write a small program to read your packages.config/csproj files as XML, find unique list of packages that you use, then write a new SDK-based csproj targeting .NET Core with all the packages you just found as package references.

How to use Bootstrap in an ASP.Net Core 2.0 Application?

I know that Bower is not recommended to be used with ASP.Net Core 2.0. Instead, I used NuGet to download Bootstrap dependency into my project. Therefore, I can't reference the files in my Layout view like I used to do with Bower using:
<link href="~/lib/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
I am trying to use NuGet to get a cleaner code. However, I can't seem to be able to reference this package in my project. Anyone has an idea how to use/reference bootstrap installed through NuGet in an ASP.Net Core 2.0 application?
In .NET Core, Nuget is no longer suitable for deploying client files. This was a design decision made by Microsoft. Instead, you can use any of a host of client build/deploy tools like npm, or my preference is to simply link to the libraries you need st a CDN location. This eliminates deployment issues and offers better performance for your users.
In Visual Studio 2017 Preview, you can use Library Manager:
Library Manager (“LibMan” for short) is Visual Studio’s experimental
client-side library acquisition tool. It provides a lightweight,
simple mechanism that helps users find and fetch library files from an
external source (such as CDNJS) and place them in your project.
Soon it will available in VS stable version.
Add the "Package Installer" and "Bundler & Minifier" Extensions into Visual Studio (both created by Mads Kristensen)
Use the Package Installer to install client libraries using "npm" which is widely supported.
This downloads the files to a node_modules folder in the root of your web project.
Use Bundler & Minifier to copy/bundle/minify as you like for dev and/ or production from the node_modules folder to where you want them in the wwwroot folder.
First, install a nmp configuration file, and add bootstrap like in bower.json and save. Visual studio will download it. This is available for all packages. You can find the installed packages in the nmp node under the dependencies node of your project. Find more informations here

Share proxy/sequences references between ESBConfiguration projects

We have the following problematic :
we have an ESB Configuration project containing proxies/sequences that we want to reuse inside an other ESB Configuration Project (we just want to reference them not to copy) and finally build them inside the same CAR.
How can we do it with DeveloperStudio/maven ?
Tks
Nicolas
All developer studio projects are fully maven comfortable . Please follow the following steps to create projects
Create maven multi-module project.
Then create the ESB configuration project(As a best practice do it inside the
Multi-module project.).
Create relevant ESB artifact(Proxy/Sequence) inside that ESB config project.
Finally create the Composite application project (As a best practice do it inside the
Multi-module project too).
Now go to the maven multi-module project location and build it(mvn clean install)
Once build succeed ,you can find the Car file inside composite application target directory
You not need to build project by project just build the multi-module project only.
Hope this help !!

Using XCore generated classes in a war aggregating multiple Maven projects

I have a maven project called myproject.app. I also have another project using vaadin and gwt called myproject.ui and another project, which is an Xcore-Project converted to Maven called myproject.model.
I want to aggregate them all in a war. For this I have a myproject.war with a pom declaring the dependencies.
For Vaadin and GWT everthing is working fine as these projects are pure maven projects. The Xcore project gives me headaches because I can't manage to provide the Plugin Dependencies declared in this project in the war.
I have tried to add the needed libraries in the pom but I can only get old versions (2.2.3) from Central - the XCore project uses 2.8./3.8..
How can I solve this?
The answer is to convert the eclipse dependencies (EMF, XCore ...) to maven artifacts using the Maven Tools 4 Eclipse.
http://wiki.eclipse.org/MT4E_FAQ
For professional usage it is necessary to setup a maven repository, I used Nexus with success (if you are developing locally and alone it would be enough to install the artifacts in you local repository).
http://www.sonatype.org/nexus/
You can get it working by setting up a hosted repository with the converted Eclipse artifacts (documented in the mt4e reference) and creating a repository group aggregating the preconfigured maven central proxy and the hosted repository with the eclipse artifacts.
You need to setup your local settings.xml to use the nexus and you're good to go. Eclipse's artifacts are usable via maven coordinates.
Keep the orbit artifacts in mind and design your patch files carefully.

Resources