Spring Tool Suite 4 Console Color issue - console

I'm developing a Spring Boot application with Spring Tools Suite 4. I don't know why but most of the log messages are highlighted in red color. Only the spring boot logo has a normal color highlighting.
I have the following setup:
STS-4.2.2
Maven 3.6.1
spring.output.ansi.enabled=always
Windows 7 with an older powershell version (if that even matters)
Eclipse console settings are standard (only syserr should create red events).
Did I miss something? Thanks for your help

I found the problem. I expected standard Spring Boot Logging to be in place (which is Logback). But this library was not included. So by adding this dependency, everything works like a charm.
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>

Related

Creating a fat jar for Dropwizard application

I am trying to create a fat jar for a multi module java project following the dropwizard documentation that makes use of the maven shade plugin.
https://dropwizard.github.io/dropwizard/getting-started.html#building-fat-jars
In order to do this I created another aggregator project which is just another pom.xml and configured the plugin in this pom.xml
Is there a way I can add my classpath in this configuration? What am I missing?
For all those interested. I fixed the issue by forcing Guava version 12 that the application gets from dropwizard.

Spring boot hot deployment for templates and resources under IntelliJ

Is anyone aware of a mechanism to get hot deployment for resources and template working under IntelliJ 14.0.2 for a Spring Boot application.
I know that full Spring Boot support is scheduled for 14.1 but I have a project that I converted over from a standard WAR project to a Spring Boot project and I really miss the hot deployment.
At the moment I have to manually build the project that the resources are in to get hot deployment and even then it is a bit flaky sometimes. I would prefer to just save a template or a javascript/css file and get it picked up as I did when I was running my app using a local tomcat server via IntelliJ.
I could switch back to Eclipse to get this working, but my project is Scala based and IntelliJ Scala support is far superior.
So after some testing I came to few conclusions I think someone arriving here may find useful:
If you are running embedded spring boot application from IntelliJ IDEA (myself on 14 at the moment) in debug mode and you want to hot re-deploy resources you can do that via: Run -> Reload changed classes. Setting a keyboard shortcut much recommended.
Don't get fooled by Loaded classes are up to date. Nothing to reload. message. Your static resources have been updated (tested on .js files and Thymeleaf templates).
As pointed out in comments for thymeleaf templates hot-redeploy you would need:
spring.thymeleaf.cache=false
If you are running in external container IntelliJ provides extra features like action on Frame deactivation which is extremely handy for web development. This works fine as well just beware that external Jetty container on 9.2.7 will cause troubles, i.e. unload the resources on Update resources action breaking your webapp. The only fix was app restart for me. Works nicely in Tomcat 8 though.
As instructed here adding spring-boot-devtools dependency will enable static resources reloading (templates and css).
Beware that you need to select Build -> Compile for this to work.
Install jetbrains-ide-support
Start your Spring Boot app
Go in browser and open your_project_page(http://localhost:8080/)
right mouse click(on your page) -> choose "Inspect in IDEA"

JAVAFX not being picked up in runtime from Spring STS with Java 8 on Mac

I've installed Java 8 and Spring STS on Mac. Running jjs from the command line works. However, when trying to create a new class in a Maven project in STS, the editor doesn't recognise the javafx.* package automatically.
Attached you'll find an example of an image showing that the only Label object suggested is the java.awt one.
Any idea on how I could solve this?
Regards,
M.
I think this is related to the settings of your project. If your project is created with an execution environment JavaSE-1.8, this execution environment doesn't have the javafx API defined as accessible and you would need to manually allow that. If you choose the 1.8 JRE (as a JRE, not an execution environment) in your project settings, the JavaFX API is accessible and works nicely in content-assist, quick fix, etc. This is at least the case if you create a standard Java project.

Java/Flash application not working when compiled with flex-mojo

I'm working on a Java web application which contains some Flash modules.
So far I've used Adobe Flash builder to compile the Flash source code and manually integrate the swf file into the war, and the web application can be deployed and runs successfully.
Recently the customer, who also is the source code proprietary, asked for managing the Flash source modules using the flex-mojo maven plugin.
The problem is that the application compiles and is deployed with no errors but no longer works. When you access the application from a browser after the login phase a blank screen appears and there is no way to interact with the application.
The pom.xml used to build the Flash module is the following (I omitted irrelevant parts):
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>4.0-RC2</version>
<extensions>true</extensions>
<configuration>
<contextRoot>myapp</contextRoot>
<services>../myapp-war/src/main/webapp/WEB-INF/flexCompile/services-config.xml</services>
<localesSourcePath>${basedir}/locale/{locale}</localesSourcePath>
<debug>true</debug>
<output>target/myapp.swf</output>
<definesDeclaration>
<property>
<name>BUILD::buildNumber</name>
<value>"Versione: ${project.version}"</value>
</property>
</definesDeclaration>
<localesRuntime>
<locale>en_US</locale>
</localesRuntime>
<localesCompiled>
<locale>en_US</locale>
</localesCompiled>
</configuration>
</plugin>
</plugins>
It's important to notice that the size of the two compiled swf files are different, so this seems to be a compiler version issue.
Is there anyone who uses to develop with Flash and Java that can give me some hint about solving this issue, even just pointing me to resources, forums, and so on?
Did you try setting the swfVersion property to your configuration? It would be something like this:
<swfVersion>13</swfVersion>
The version is specific to your targeted player. You can find which version you need here
As a general good practice, do not forget to check myapp-config.xml which contains every options passed by Flexmojo to mxmlc. This file is located in your target directory.

Handling server JAR in maven

There are some server jars in my project which i want to migrate to maven ..
I don't have any idea how can i have dependencies attached to these jars.. there are almost 24 jars.. So how can add them to the project scope
The approach you can take depends on whether you have access to the sources of those 'server' jars or not. If you do, then nothing prevents you from creating one/more Maven projects, packaging these and deploying them in your Maven repository.
If you don't have access to the sources and these aren't already available in official Maven repositories, then all you can do is put those in your Maven repository by using maven install:
Often times you will have 3rd party JARs that you need to put in your local repository for use in your builds. The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Maven. To make this easier, and less error prone, we have provide a goal in the install plug-in which should make this relatively painless.
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
Once done for all of these jars, just add dependencies to your project.
I don't recommend you add the server jars in your POM, instead I just use the API jar
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
The advantage is you are conforming to a portable standard. M2E will compile things correctly and it will still run your application correctly when deployed to the runtime provided it supports the API.
If you want to explicitly see it you can add the runtime by going to the project preferences then going to Targetted Runtimes. You only need to do it on the EAR it will do the included projects in the EAR for you. The advantage of adding the targetted runtime is Eclipse may do extra validation specific for your server.

Resources