Un problema habitual en Maven son las dependencias heredadas de otras dependencias, especialmente cuando queremos evitar añadir un .jar concreto. Para solucionar este problema tenemos 2 herramientas sencillas y rápidas.
Con 'mvn dependency:tree' podemos saber que dependencias están importando nuestras dependencias. A continuación debemos añadir una nueva entrada en las '<exclusions>' de nuestra dependencia.
Para evitar que en un futuro vuelva a aparecer dicha dependencia, podemos usar el plugin siguiente:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<!-- exclude all versions lower than 1.2.17-->
<exclude>log4j:log4j:[0.0,1.2.17)</exclude>
</excludes>
</bannedDependencies>
</rules>
</configuration>
</execution>
</executions>
</plugin>
con este plugin se obtiene un error cuando se esta detectando una dependencia rechazada.
______________________________________________
A common problem with Maven is to know what dependencies are being imported by our own dependencies, especially when we try to avoid a particular .jar file. This problem is esasily solved with two tools.
'mvn dependency:tree' allows us to know all the dependencies imported and which one imports another one. Adding a new entry in '<exclusions>' section of this dependency, we avoid the corresponding file.
To force that in a future this dependency will not be impoerted again, we can use the following plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<id>enforce-version</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<!-- exclude all versions lower than 1.2.17-->
<exclude>log4j:log4j:[0.0,1.2.17)</exclude>
</excludes>
</bannedDependencies>
</rules>
</configuration>
</execution>
</executions>
</plugin>
With this plugin you get an error when this dependency is detected again.
Programaando
Ando programando
lunes, 25 de julio de 2016
viernes, 6 de febrero de 2015
Migración de MySQL 5.5 a 5.6/ Migration from MySQL 5.5 to 5.6
- Crear una copia: mysqldump (shell> mysqldump --single-transaction --all-databases > bd_backup_20150115.sql;) o workbrench
- linux: es bueno comenzar con una actualizacion: sudo apt-get update
- detener el servicio de MySQL (consider setting innodb_fast_shutdown to 0 before shutting down, en InnoDB el apagado es mas lento y tendría q estar totalmente apagado)
- windows: NET STOP MySQL | C:\> "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqladmin" -u root shutdown
- linux:
- check: sudo service mysql status
- stop: sudo service mysql stop
- por si la nueva versión da problemas con el arranque: mantener la anterior con un rename de mysqld (/usr/sbin/mysqld -> /usr/sbin/mysqld-5.5) y hacer una copia de la configuracion actual (my.cnf o my.ini)
- lanzar la actualizacion
- windows: installer
- Red Hat:
- copiar el instalador mysql-apt-config_0.3.2-1ubuntu12.04_all.deb (para lanzar el apt-get)
- añadir el fichero anterior al repo: sudo dpkg -i mysql-apt-config_0.3.2-1ubuntu12.04_all.deb
- sudo apt-get install mysql-server
- sudo apt-get install libmysqlclient18
- CIUDADO!! en mi caso uso el python connector y en la version 2.0.2 daba un error de perdida de conexion y en la 2.0.3 no lo daba pero se quedaba colgado, por lo que he instalado el 1.2.3
- Mantener los parametros que han cambiado de valor por defecto para que funcione bien lo que teniamos, poniendo la siguiente configuracion en el fichero:
- windows: my.ini en el directorio raiz
- linux: my.cnf en el directorio raiz (/etc/mysql/my.cnf)
- [mysqld]
innodb_file_per_table=0
innodb_checksum_algorithm=INNODB
binlog_checksum=NONE - Lanzar la comprobación de las tablas y que se actualicen/corrijan si hace falta (shell> mysql_upgrade -u root -p)
- rearrancar el servicio / programa
- windows: NET START MySQL / mysqld
- linux: sudo service mysql start
____________________________________________
- Create a backup: mysqldump (shell> mysqldump --single-transaction --all-databases > bd_backup_20150115.sql;) or workbrench
- linux: it is advisable to update the system: sudo apt-get update
- Stop the MySQL service (consider setting innodb_fast_shutdown to 0 before shutting down, in InnoDB the stop action takes more time and it is necessary a complete stop)
- windows: NET STOP MySQL | C:\> "C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqladmin" -u root shutdown
- linux:
- check: sudo service mysql status
- stop: sudo service mysql stop
- Safety actions: keep a copy, with a rename, of mysqld (/usr/sbin/mysqld -> /usr/sbin/mysqld-5.5) an another of the current configuration (my.cnf o my.ini)
- Launch the actualization
- windows: installer
- Red Hat:
- copy the instaler mysql-apt-config_0.3.2-1ubuntu12.04_all.deb (to launch the apt-get)
- adding the file to the repo: sudo dpkg -i mysql-apt-config_0.3.2-1ubuntu12.04_all.deb
- sudo apt-get install mysql-server
- sudo apt-get install libmysqlclient18
- CAREFUL!! the python connector version 2.0.2 had a problem with connection and version 2.0.3 does not return the "lost connection error" but is frozen the thread, so I had to install the version 1.2.3
- Keeping the value of the paremeters that has change the default value in this version, so the following configuration must be added to configuration file:
- windows: my.ini (mysql path or "Program Data" folder)
- linux: my.cnf (path /etc/mysql/my.cnf)
- [mysqld]
innodb_file_per_table=0
innodb_checksum_algorithm=INNODB
binlog_checksum=NONE - Checking problems and updating tables (shell> mysql_upgrade -u root -p)
- Starting the service or program
- windows: NET START MySQL / mysqld
- linux: sudo service mysql start
- 5.5 to 5.6: http://dev.mysql.com/doc/refman/5.6/en/upgrading-from-previous-series.html
- APT upgrade: http://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/index.html#repo-qg-apt-upgrading
- windows upgrade: http://dev.mysql.com/doc/refman/5.6/en/windows-upgrading.html
martes, 24 de junio de 2014
SSL, keystores, truststores and 2-way-SSL
Con esta entrada pretendo aclarar estos conceptos y mostrar algún comando de interés.
SSL: capa de conexión segura, nos permite intercambiar información de forma cifrada a través de la red, dicho de otra forma, no visible para el resto.
El Java KeyStore (JKS) es un repositorio de certificados de confianza (con sus claves privadas). El propósito final es proveer las credenciales.
El TrustStore (JKS) es un repositorio de certificados de confianza (con sus claves publicas). Este sirve, por ejemplo, para negociar la conexión SSL entre el cliente y el servidor. El propósito final es validar las credenciales.
Two-Way SSL: es un método de autenticación donde la aplicación cliente verifica la identidad de la aplicación servidora y luego la servidora verifica la identidad del cliente.
Si hablamos de certificados, debemos aclarar el termino CA que se corresponde con una entidad certificadora (emite y revoca los certificados). Lo primero es confiar en la propia CA para lo que se suele recurrir a la instalación (añadir al truststore) del certificado autofirmado de la CA.
This blog post I'll try to explain several concepts and show the main commands about SSL.
SSL: Secure Sockets Layer, it makes encryption communication, so our information will not be visible to another person or system.
A Java KeyStore (JKS) is a repository of security certificates (with private keys). The final purpose is to provide the credentials.
A TrustStore (JKS) is a repository of security certificates (with public keys). This is useful for establish a SSL connection between a client and a server. The final purpose is to validate the credentials.
Two-way SSL: is a authentication method where client application verify the identity of the server application and, after that, server verify the identity of the client.
When we speak about certificates, we must considerer the CA, Certificate Authority (who releases and revokes the certificates). The first step is to trust in the CA so you must to install (add to truststore) the CA self-signed certificate.
SSL: capa de conexión segura, nos permite intercambiar información de forma cifrada a través de la red, dicho de otra forma, no visible para el resto.
El Java KeyStore (JKS) es un repositorio de certificados de confianza (con sus claves privadas). El propósito final es proveer las credenciales.
El TrustStore (JKS) es un repositorio de certificados de confianza (con sus claves publicas). Este sirve, por ejemplo, para negociar la conexión SSL entre el cliente y el servidor. El propósito final es validar las credenciales.
Two-Way SSL: es un método de autenticación donde la aplicación cliente verifica la identidad de la aplicación servidora y luego la servidora verifica la identidad del cliente.
Si hablamos de certificados, debemos aclarar el termino CA que se corresponde con una entidad certificadora (emite y revoca los certificados). Lo primero es confiar en la propia CA para lo que se suele recurrir a la instalación (añadir al truststore) del certificado autofirmado de la CA.
Comandos
Los principales comandos para el manejo de certificados los ofrece el kit keytool de Java.
- listar certificados en el keystore
- keytool -list -v -keystore $keystore.jks
- obtener los certificados del servidor
- openssl s_client -connect $ip:$port -prexit -showcerts
- Caducidad de un certificado .pem
- openssl x509 -in $cert -noout -enddate
- Información del certificado
openssl pkcs12 -in$cert.p12 -info- Generar un certificado .pem desde un p.12
- openssl pkcs12 -in $cert.p12 -out $finalCert.pem
- Importar un certificado de una CA en un keystore
- keytool -import -trustcacerts -alias root -file $cacert.crt -keystore $keystore.jks
- Generar un keystore con un certificado auto-firmado (para pruebas)
- keytool -genkey -keyalg RSA -alias $selfsignedAlias -keystore $keystore.jks -storepass $password -validity $numberDays -keysize 2048
- (otra opción) openssl req -new -x509 -sha256 -newkey rsa:2048 -days 365 -nodes -out /path/cert.pem -keyout /path/cert.key
____________________________________________
This blog post I'll try to explain several concepts and show the main commands about SSL.
SSL: Secure Sockets Layer, it makes encryption communication, so our information will not be visible to another person or system.
A Java KeyStore (JKS) is a repository of security certificates (with private keys). The final purpose is to provide the credentials.
A TrustStore (JKS) is a repository of security certificates (with public keys). This is useful for establish a SSL connection between a client and a server. The final purpose is to validate the credentials.
Two-way SSL: is a authentication method where client application verify the identity of the server application and, after that, server verify the identity of the client.
When we speak about certificates, we must considerer the CA, Certificate Authority (who releases and revokes the certificates). The first step is to trust in the CA so you must to install (add to truststore) the CA self-signed certificate.
Commands
The main commands to managament of certificates are offers by the keytool kit of Java.
- Listing of certificates in the keystore
- keytool -list -v -keystore $keystore.jks
- Getting all certificates from the server
- openssl s_client -connect $ip:$port -prexit -showcerts
- Getting informatión about the certificate
openssl pkcs12 -in$cert.p12 -info- Expiration date of a certificate (.pem format)
- openssl x509 -in $cert -noout -enddate
- Generating a certificate with format .pem from format p.12
- openssl pkcs12 -in $cert.p12 -out $finalCert.pem
- Import a root or intermediate CA certificate to an existing Java keystore
- keytool -import -trustcacerts -alias root -file $cacert.crt -keystore $keystore.jks
- Generate a keystore and self-signed certificate (for testing purposes)
- keytool -genkey -keyalg RSA -alias $selfsignedAlias -keystore $keystore.jks -storepass $password -validity $numberDays -keysize 2048
- (another option) openssl req -new -x509 -sha256 -newkey rsa:2048 -days 365 -nodes -out /path/cert.pem -keyout /path/cert.key
jueves, 12 de junio de 2014
Mejores ofertas / The best discounts
Hola,
He participado, junto con un compañero, en la creación de una web que permite obtener las mejores ofertas en Rakuten, el nuevo marketplace que viene pegando fuerte. Poco a poco iremos completando la funcionalidad ofrecida y, quizás en un futuro próximo, permitiendo comprar precios de distintos sitios para encontrar el producto mas interesante o que mas haya bajado de precio.
Querría compartirlo con vosotros, por si la página os pudiera ser útil. El sitio se llama:
http://locosporlasrebajas.com/
Cualquier comentario sobre la misma será bien recibido.
_______________________________________________
Hello,
I have participated, with a friend, in the development of a new site with the best discounts of Rakuten, the new marketplace which arrives strong. As soon as posible, we will try to add new functionality and, probably, to compare prices from differents marketplaces so you could find a product with the better price.
I want to share this site with you, perhaps it is useful for somebody. The website is:
http://locosporlasrebajas.com/
Every comment about the website will be thankful.
He participado, junto con un compañero, en la creación de una web que permite obtener las mejores ofertas en Rakuten, el nuevo marketplace que viene pegando fuerte. Poco a poco iremos completando la funcionalidad ofrecida y, quizás en un futuro próximo, permitiendo comprar precios de distintos sitios para encontrar el producto mas interesante o que mas haya bajado de precio.
Querría compartirlo con vosotros, por si la página os pudiera ser útil. El sitio se llama:
http://locosporlasrebajas.com/
Cualquier comentario sobre la misma será bien recibido.
_______________________________________________
Hello,
I have participated, with a friend, in the development of a new site with the best discounts of Rakuten, the new marketplace which arrives strong. As soon as posible, we will try to add new functionality and, probably, to compare prices from differents marketplaces so you could find a product with the better price.
I want to share this site with you, perhaps it is useful for somebody. The website is:
http://locosporlasrebajas.com/
Every comment about the website will be thankful.
viernes, 21 de febrero de 2014
Nueva web / New site
Hola a todos, sé que este tema no está relacionado directamente con el desarrollo y la programación, pero a nivel personal he estado trabajando en un nuevo proyecto y me gustaría comentarlo.
Se trata del desarrollo de una página web:
http://articulosparaelcazador.com/
Cualquier comentario sobre la misma será bien recibido.
_______________________________________________
Hello, this article is not directly related with development and programming, but I am involved in a personal proyect and I would like to tell to everyone.
It is about a new website (now there is only Spanish version, sorry for inconveniences):
http://articulosparaelcazador.com/
Every comment about the website will be thankful.
martes, 4 de febrero de 2014
Principales diferencias entre las distintas versiones de Java / Main differences between Java versions
1.4
- assert keyword
x = 1;
assert (x != 0);
assert (x != 0);
- Regular expressions
Pattern p = Pattern.compile("fish");
Matcher m = p.matcher("one fish, two fish, red fish, blue fish");
while (m.find()) {
Matcher m = p.matcher("one fish, two fish, red fish, blue fish");
while (m.find()) {
/*...*/
}
}
- IPv6 support
Se modificaron clases para soportar IPv6, como por ejemplo InetAddress, MulticastSocket, etc.
- Logging
Properties file with all configuration for logs
- XML parser and XSLT processor (JAXP)
Transformer xmlTransformer = TransformerFactory.newInstance().newTransformer(
new StreamSource(new StringReader(xsltResource))
);
_______________________________________
Document doc = parseFile(xmlFileName);
Node root = doc.getDocumentElement();
- Integrated security and cryptography extensions (JCE, JSSE, JAAS)
SSLServerSocketFactory sslSrvFact = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
s =(SSLServerSocket)sslSrvFact.createServerSocket(port);
SSLSocket c = (SSLSocket)s.accept();
OutputStream out = c.getOutputStream();
InputStream in = c.getInputStream();
- Preferences API
String value = (String) myPreferences.get(key, defaultValue);
5 (1.5)
- Generics
List<String> l = new ArrayList<String>();
l.add("string");
- Metadada (annotations)
@Override
@MethodInfo(author = 'Pankaj', comments = 'Main method', date = 'Nov 17 2012', revision = 1)
public String toString() {
return 'Overriden toString method';
}
- Enhanced for loop
for (String s: stringList) {
System.out.println(s);
}
- Enumerations
public enum Currency {PENNY, NICKLE, DIME, QUARTER};
- Varargs
void printReport(String header, int... numbers) {
for (int num : numbers) {
System.out.println(num);
}
}
- Concurrency utilities
Classes like: Semaphore, Executors, SynchronousQueue<E>, ... in java.util.concurrent.
6
- Scripting Language Support
- Improved Web Service support through JAX-WS
- [performance improvements]
- Upgrade of JAXB to version 2.0
- Support for pluggable annotations
7
- String in switch
- Allowing underscores in numeric literals
- Catching multiple exception types and rethrowing exceptions with improved type checking
- Lambda (anonymous function)
- Concurrency utilities
static final int AVAILABLE_PROCESSORS = Runtime.getRuntime().availableProcessors();
final ForkJoinPool pool = new ForkJoinPool(AVAILABLE_PROCESSORS);
8
- Lambda expressions
printPersonsWithPredicate(
roster,
p -> p.getGender() == Person.Sex.MALE
&& p.getAge() >= 18
&& p.getAge() <= 25
);
- Allows developers to embed JavaScript code (Project Nashorn)
- Annotations on Java Types
List<@NonNull Object>
- Date and Time API
domingo, 14 de abril de 2013
Eclipse: SVN plugins
Actualmente Eclipse cuenta con dos plugins principales para acceder a repositorios SVN: Subversion de Tigris (probado el cliente v. 1.8.0 con core v. 1.8.4) y Subversive (probado el conector v. 2.2.2 con Team Provider v. 0.7.9).
Estoy trabajando con ellos en diferentes entornos y como resultados de las pruebas puedo decir:
Nowadays Eclipse has two main plugins when you work with SVN: Subversion of Tigris (I have tested the client v. 1.8.0 with core v. 1.8.4) and Subversive (I have tested the conector v. 2.2.2 with Team Provider v. 0.7.9).
I am working with both of them in different IDEs and I have concluded the following:
Estoy trabajando con ellos en diferentes entornos y como resultados de las pruebas puedo decir:
- Subversive esta mejor preparado para trabajar con branches/tags
- Commits y descargas son similares
- Tigris ofrece un enlace directo a "Update to HEAD" mientras que con Subversive tienes que buscar esa versión en el "Update to Revision..."
- Tigris ofrece para el control, como herramientas adicionales, "Show Revision Properties" y "Show Revision Graph"
- En caso de conflicto se comportan de forma similar, salvando que Tigris no tiene un "Overwrite and commit" por lo que antes de poder hacer el "Commit" habría que lanzar un "Mark as merged"
- A la hora de hacer el commit, Tigris ofrece la posibilidad de hacer un "Compare With" de los elementos modificados
- Ambos funcionan mal para el borrado de elementos locales (si el borrado ha sido en remoto lo actualizan sin problemas), dando bastantes problemas, especialmente si lo que se pretende es rehacer algo que se ha eliminado sin hacer el commit de por medio:
- Subversive no hace bien el commit pero tampoco da avisa con algún error
- Tigris, además de indicar que el cambio es por un borrado, si que da un error
- Eliminando primero los ficheros y después las carpetas ya vacías, Tigris si que acaba haciendo el commit (si no se ha intentando regenerar nada) mientras que Subversive sigue sin subir los cambios
Nowadays Eclipse has two main plugins when you work with SVN: Subversion of Tigris (I have tested the client v. 1.8.0 with core v. 1.8.4) and Subversive (I have tested the conector v. 2.2.2 with Team Provider v. 0.7.9).
I am working with both of them in different IDEs and I have concluded the following:
- Subversive is better prepared to work with branches/tags
- Commits and downloads work similar with both of them
- Tigris offers a shortcut with "Update to HEAD" while with Subversive you have to find this version with "Update to Revision..."
- Tigris offers additional tools for control like "Show Revision Properties" and "Show Revision Graph"
- In case of conflict they work similar, but Tigris has not got "Overwrite and commit" so you have to clic in "Mark as merged" before do the "Commit"
- When make a commit, with Tigris you can use the option "Compare With" with the modified elements
- Both of them do not work correctly when you delete local elements (if it has been in remote, they update the changes without any problem), giving problems, especialy when you try to redo something without do a commit before:
- Subversive does not the commit but it also does not any warning
- Tigris, in addition to marking the change of type erasure, get an error
- When you firstly remove files and after that remove empty folders, Tigris does a correct commit (if you did not redo anything) while Subversive continued without do the changes
Suscribirse a:
Entradas (Atom)