Tuesday, September 11, 2018

Spring: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ...: Unsatisfied dependency expressed through field


>PROBLEM
Starting the application, it stops working throwing the following exception:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ulteringController': Unsatisfied dependency expressed through field 'stateSvc'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'estadoSvc': Unsatisfied dependency expressed through field 'estadoRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'estadoRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Could not create query metamodel for method public abstract br.com.ultering.model.State br.com.ultering.model.repository.EstadoRepository.findBySigla(java.lang.String)!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.9.RELEASE.jar:4.3.9.RELEASE]


>SOLUTION

@Autowired
private StateSvc stateSvc;

ORIGINAL

@Service("estadoSvc")
@Transactional
public class StateSvcImpl extends AbstractSvc implements StateSvc {

FIXED

@Service("stateSvc")
@Transactional
public class StateSvcImpl extends AbstractSvc implements StateSvc {


>ENV
Windows
Spring Boot

Saturday, June 16, 2018

git: Resolving .gitignore issue in a messy project

PROBLEM
There many different .gitignore files into your project.
The ".gitignore" seams not working at all.
Your pull like commands comes with "ignored files".
SOLUTION
  1. Create a .gitignore pattern.
  2. Fix your repository's .gitignore file into master, at least.
    Same to develop or another very used branch.
  3. After updating or merging your local stuff, check the .gitignore content.
    If the local .gitignore file is not like the pattern, just overwrite it with the pattern file.
    If your project is too messy,  simply overwrite local using the pattern as a "just after procedure", to make sure.
  4. Avoid having more than one .gitignore file.
    Set just one under the project's root dir.
    In most of all usual cases, is enough.

.gitignore Example of a Java Project With Sonar and Docker files.

# Add any directories, files, or patterns you don't want to be tracked by version control
# ECLIPSE'S
**/target
**/.settings
**/.apt_generated
**/.metadata
*.classpath
*.factorypath
*.project
*.class
*.tern-project
# PROJECT'S STUFF
*.Jenkinsfile
*.JenkinsfileTeste
*.arquivoPdf.txt
*.arquivoPng.txt
*.arquivoXls.txt
*.axis.log
# TO BE USED TO LOG REPORTS AND MAINTENANCE

#WHY .GITIGNORE SEEMS TO FAIL

Follow the figures below.




After fixing .gitignore file:




Another reason when .gitignore fails is caused by a "conflicting state".



*.log.out
 @FROM: my alternative site

Wednesday, April 25, 2018

Maven exception "Fatal error compiling: invalid target release:..."

>PROBLEM
When running "mvn clean install" you get:
  Fatal error compiling: invalid target release:


>SOLUTION
Set JAVA_HOME envvar or include it into the script which runs maven.
  export JAVA_HOME="/home/portables_d/jdk1.8.0_144"

>ENV
linux/debian

Maven fails to load spring references



>PROBLEM
Maven fails to load spring references

Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from http://maven.repository.redhat.com/ga/ was cached in the local repository, resolution will not be reattempted until the update 
 interval of redhat-ga-repository has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to redhat-ga-repository (http://
 maven.repository.redhat.com/ga/): maven.repository.redhat.com





>SOLUTION
Check the repository location into ".m2\settings.xml".

For instance:
C:\Users\YourLogin\.m2\settings.xml

In this case the localRepository was configured with linux's location and not windows as it was supposed to be:

***WRONG:
/home/portables_d/mvnlibs

+++RIGHT:
${env.LOCAL}\portables_d\mvnlibs



>ENV
windows
eclipse
java8

Tuesday, March 6, 2018

Remove dashboard bar to a profile from WordPress site


METHOD #1 - Plugin

Suppose that you have a site that you desire to supress the dashboard bar and admin bar to the users except the administrators.

Use "Editor Menu And Widget Access" plugin and just set the configuration like this:




-----------------------------------------------------------------------------------------------------------
METHOD #2 - Coding

@DEPRECATED:
In recent versions using others themes, the solution was not effective anymore, requiring more code digging. A better alternative solution was adopted above.


Suppose that you have a site that you desire to supress the dashboard bar and admin bar to the "subscriber" profile.
Follow the example.

1. Go to the themes' function.php file.
For instance, if the active theme is named "vale", edit:
$SITE_DIR/public_html/wp-content/themes/vale/function.php

2. Add the following

// This file is not called from WordPress. We don't like that.
! defined( 'ABSPATH' ) and exit;

add_action( 'init', 'fb_remove_admin_bar', 0 );
function fb_remove_admin_bar() {
if ( current_user_can('subscriber') || current_user_can('assinante') ) {
wp_deregister_script( 'admin-bar' );
wp_deregister_style( 'admin-bar' );
remove_action( 'init', '_wp_admin_bar_init' );
remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
// maybe also: 'wp_head'
foreach ( array( 'admin_head' ) as $hook ) {
add_action(
$hook,
create_function(
'',
"echo '';"
)
);
}
}
}


Adapted from:
https://wordpress.stackexchange.com/questions/77639/disable-the-admin-bar/77648#77648

Remove excert from WordPress standard search



The standard search box generates by default a list of titles and excerpts.

The bold text is the title, the other (smaller characters) is the excerpt.

To exclude the excerpt from the default search, check the theme the site is using.
In this example is TwentyFifteen.
Go to the theme's folder and follow the procedure below.



1. Edit content-search.php.
This file is at:

/home/mynumbers/public_html/wp-content/themes/twentyfifteen/content-search.php


2. Remove the entry in orange:

 <header class="entry-header">
  <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
 </header><!-- .entry-header -->

 <div class="entry-summary">
  <?php the_excerpt(); ?>
 </div><!-- .entry-summary -->

 <?php if ( 'post' == get_post_type() ) : ?>
NOTE: always take note of a reference from where the code was remove in order to rollback, just in case.

After this procedure, just the bold title shall appear.


eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...