Git Product home page Git Product logo

Comments (4)

patka avatar patka commented on August 17, 2024

Hi Ebeid,

did you do some changes to your Spring applications configuration lately? Usually, when you use the spring boot starter library, it should replace the default JarLocationScanner with the SpringBootLocationScanner that knows how to handle the some specialties that are introduced by Spring. According to you log output, your application is still using the JarLocationScanner. To me it seems that the Spring auto configuration is not executed. Can you verify this?

Do you have this problem only when you start the standalone jar or also when you run the application inside your IDE.

Cheers
Patrick

from cassandra-migration.

Ebeid avatar Ebeid commented on August 17, 2024

Thanks for the quick pointer Patrick.

We fixed the error by explicitly using SpringBootLocationScanner in our implementation below:

@SpringBootApplication(scanBasePackages={"com.myservice"})
public class MyServiceApplication {

	private static final Logger logger = LoggerFactory.getLogger(MyServiceApplication.class);

	public static void main(String[] args) {
		Builder b = Cluster.builder().addContactPoint(EnvironmentVariables.getCassandraHost());
		b.withPort(Integer.parseInt(EnvironmentVariables.getCassandraPort()));
		Cluster cluster = b.build();

		Database database = new Database(cluster, EnvironmentVariables.getCassandraKeySpace());
		MigrationTask migration = new MigrationTask(database, createMigrationRepository());
		migration.migrate();

		run(MyServiceApplication.class, args);
	}

	private static MigrationRepository createMigrationRepository(){
		ScannerRegistry registry = new ScannerRegistry();
		registry.register(ScannerRegistry.JAR_SCHEME, new SpringBootLocationScanner());
		return new MigrationRepository("cassandra/migration", new IgnoreDuplicatesCollector(), registry);
	}
}

While we fixed our problem we realized that CassandraMigrationAutoConfiguration was running a second time after our custom migration (depicted above) runs and Spring server starts.

To prevent this we fall back to using:

compile('org.cognitor.cassandra:cassandra-migration:2.1.2')

And including SpringBootLocationScanner source to our codebase and refer from there.

Thanks again!

from cassandra-migration.

patka avatar patka commented on August 17, 2024

Hi Ebeid,

normally you should be able to exclude the CassandraMigrationAutoConfiguration in your configuration code like this:

@EnableAutoConfiguration(exclude = CassandraMigrationAutoConfiguration.class)

This would allow you to use the SpringBootLocationScanner from the dependency without making a copy into your codebase which is in general not a good practice as you will be excluded from every update that will happen to it.

Does the Spring auto configuration not work for you? As far as I can tell you are not doing anything special except for the IgnoreDuplicatesCollector.

Cheers
Patrick

from cassandra-migration.

ChandraDuddukuri avatar ChandraDuddukuri commented on August 17, 2024

Hallo Patrick,
While using version 2.2.0 on windows, with both the Jars included, my Spring boot Maven application is working fine. But when is used it on Linux, i am facing the issue as mentioned by Ebeid.

I tried the solution mentioned by Ebeid with version 2.1.2 (Scanner locally and only one Jar included) and it's working on both Windows & Linux environments.

Regards,
Chandra

from cassandra-migration.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.