问:
How to create a new instance of MobX and override the old instance using MobX with Provider?
I'm new developing with Flutter. I'm now using MobX to manage my app states and using Provider to pass the instance of my MobX Controller through screens.

The app is simple, where the user go through the screens answering the questions. Everytime a question is answered, the answer is saved on the MobX Controller. Everytime the user go to the next screen or return to the previous screen, if the field has an answer, the MobX Controller fill that answer. So, if the user return to the Main screen and start to answer the questions again, he will start where he stoped. All is working until the end of the questions.

When the user finish the answers, all the data is saved to Firebase and I need to "restart" the MobX Controller. But when I create a new instance of the MobX Controller and pass it to the older instance, the Provider insist in keep the old instance, with all the old answers.

I've tried a lot of things, and the only and incorrect way to make it works, was changing every variable of the class manually. And this is so sad, because is too much fields.

So, the question is: How can I create a new instance of my MobX Controller and make the Provider use this new instance?

Principal.dart: (the main screen of app)

```<code>void main() {
  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
  runApp(
      MultiProvider(
        providers: [
          Provider<Controller>(
            create: (BuildContext context) => Controller(),
          )
        ],
        child: MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
              primaryColor: Colors.black
          ),
          home: Main(),
        ),
      )
  );
}

class Main extends StatefulWidget {
  const Main({Key? key}) : super(key: key);

  @override
  State<Main> createState() => _MainState();
}

class _MainState extends State<Main> {

  Controller controller_mobx = Controller();
  int _conexao = 0; // 0 - SEM CONEXAO | 1 - CONECTADO
  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
    controller_mobx = Provider.of(context);
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp
    ]);
  }

  @override
  Widget build(BuildContext context) {
    Util cores = Util();
    verificar_conexao();
    double altura_imagem =MediaQuery.of(context).size.height/5;
    controller_mobx.preenche_lista_vistoria();
    FlutterNativeSplash.remove();
    return Container(
      width: double.infinity,
      height: double.infinity,
      decoration: BoxDecoration(
          image: DecorationImage(
              image: AssetImage('images/wallpaper.png'),
              //colorFilter: ColorFilter.mode(Colors.white.withOpacity(0.75), BlendMode.modulate,),
              fit: BoxFit.cover
          )
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Padding(
            padding: EdgeInsets.all(16),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Container(
                  height: altura_imagem,
                  child: Image.asset("images/logo.png"),
                ),
                Padding(
                    padding: EdgeInsets.only(top: 16, bottom: 8),
                    child: Container(
                        height: 50,
                        width: double.infinity,
                        decoration: BoxDecoration(
                          color: Colors.transparent,
                          borderRadius: BorderRadius.all(Radius.circular(15)),
                          border: Border.all(
                              color: cores.laranja_teccel,
                              width: 2
                          ),
                        ),
                        child: Material(
                          borderRadius: BorderRadius.all(Radius.circular(15)),
                          child: InkWell(
                              splashColor: cores.laranja_teccel.withOpacity(0.25),
                              hoverColor: Colors.white,
                              borderRadius: BorderRadius.all(Radius.circular(12)),
                              onTap: (){
                                Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                        builder: (context) => NovaVistoria()
                                    )
                                );
                              },
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: <Widget>[
                                  Padding(
                                    padding:EdgeInsets.only(left: 4),
                                    child: Icon(
                                      Icons.directions_car_rounded,
                                      color: cores.cor_app_bar,
                                      size: 30,
                                    ),
                                  ),
                                  Align(
                                    alignment: Alignment.center,
                                    child: Text(
                                      "Nova Vistoria",
                                      style: TextStyle(
                                        color: Colors.black,
                                        fontWeight: FontWeight.bold,
                                        fontSize: 14,
                                      ),
                                    ),
                                  ),
                                  Padding(
                                    padding:EdgeInsets.only(right: 4),
                                    child: Icon(
                                      Icons.directions_car_rounded,
                                      color: cores.cor_app_bar,
                                      size: 30,
                                    ),
                                  ),
                                ],
                              )
                          ),
                        )
                    )
                ),
              ],
            ),
          )
        ],
      ),
    );
  }

  verificar_conexao() async{
    Util verif = Util();
    _conexao = await  verif.verificar_conexao();
    if(_conexao == 0){
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => SemConexao()
          )
      );
    }
    else{
      return;
    }
  }
}
</code>```

NovaVistoria.dart: (the screen used to manage each tab of questions on app)

```<code>class NovaVistoria extends StatefulWidget {
  @override
  State<NovaVistoria> createState() => _NovaVistoriaState();
}

class _NovaVistoriaState extends State<NovaVistoria> {
  Controller controller_mobx = Controller();

  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
    controller_mobx = Provider.of(context);
  }

  Util cores = Util();

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      decoration: BoxDecoration(
          image: DecorationImage(
              image: AssetImage('images/wallpaper.png'),
              //colorFilter: ColorFilter.mode(Colors.white.withOpacity(0.75), BlendMode.modulate,),
              fit: BoxFit.cover
          )
      ),
      child: Scaffold(
          backgroundColor: Colors.transparent,
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(50),
            child: AppBar(
              title: Text('Nova Vistoria', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),),
              backgroundColor: cores.cor_app_bar,
              automaticallyImplyLeading: true,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.vertical(
                  bottom: Radius.circular(10),
                ),
              ),
            ),
          ),
          body: Observer(
            builder: (_){
              return Padding(
                  padding: EdgeInsets.all(8),
                  child: controller_mobx.abas[controller_mobx.indice_tela]
              );
            },
          )
      ),
    );
  }
}
</code>```

AbaDados.dart: (the first tab of questions)

```<code>class AbaDados extends StatefulWidget {
  const AbaDados({Key? key}) : super(key: key);

  @override
  State<AbaDados> createState() => _AbaDadosState();
}

class _AbaDadosState extends State<AbaDados> {

  Controller controller_mobx = Controller();

  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
    controller_mobx = Provider.of(context);
  }

  @override
  Widget build(BuildContext context) {
    DateTime now = DateTime.now();
    String data_relatorio = DateFormat('dd/MM/yyyy kk:mm:ss').format(now);
    if(controller_mobx.data.isEmpty)
      _controller_data.text = data_relatorio;
    else
      _controller_data.text = controller_mobx.data;
    _controller_vistoriador.text = controller_mobx.vistoriador;
    _controller_condutor.text = controller_mobx.condutor;
    _controller_modelo.text = controller_mobx.modelo_veiculo;
    _controller_placa.text = controller_mobx.placa;
    return Observer(
      builder: (_){
        return Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.only(bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                        child: Text(
                          "1 - Dados da Vistoria",
                          style: TextStyle(
                              color: cores.laranja_teccel,
                              fontSize: 24,
                              fontWeight: FontWeight.bold
                          ),
                        )
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          enabled: false,
                          controller: _controller_data,
                          keyboardType: TextInputType.name,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Data da Vistoria",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            disabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          onSubmitted: (content){

                          },
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          controller: _controller_vistoriador,
                          focusNode: _foco_vistoriador,
                          keyboardType: TextInputType.name,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Vistoriador",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          onSubmitted: (content){

                          },
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          controller: _controller_condutor,
                          focusNode: _foco_condutor,
                          keyboardType: TextInputType.name,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Condutor",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          onSubmitted: (content){

                          },
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          controller: _controller_modelo,
                          focusNode: _foco_modelo,
                          keyboardType: TextInputType.text,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Modelo do Veículo",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          onSubmitted: (content){

                          },
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          controller: _controller_placa,
                          focusNode: _foco_placa,
                          keyboardType: TextInputType.text,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.done,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Placa",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Expanded(child: Container()),
            Padding(
              padding: EdgeInsets.only(top: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                          height: 50,
                          width: double.infinity,
                          decoration: BoxDecoration(
                            color: Colors.transparent,
                            borderRadius: BorderRadius.all(Radius.circular(15)),
                            border: Border.all(
                                color: cores.laranja_teccel,
                                width: 2
                            ),
                          ),
                          child: Material(
                            borderRadius: BorderRadius.all(Radius.circular(15)),
                            child: InkWell(
                              splashColor: cores.laranja_teccel.withOpacity(0.25),
                              hoverColor: Colors.white,
                              borderRadius: BorderRadius.all(Radius.circular(12)),
                              onTap: (){
                                salvar_dados();
                              },
                              child: Align(
                                alignment: Alignment.center,
                                child: Text(
                                  "Avançar",
                                  style: TextStyle(
                                    color: Colors.black,
                                    fontWeight: FontWeight.bold,
                                    fontSize: 14,
                                  ),
                                ),
                              ),
                            ),
                          )
                      ),
                    )
                  ]
              ),
            ),
          ],
        );
      },
    );
  }
  salvar_dados(){
    if(_controller_vistoriador.text.isEmpty || _controller_condutor.text.isEmpty ||
        _controller_modelo.text.isEmpty || _controller_placa.text.isEmpty){
      final snackBar = SnackBar(
        content: const Text('Existem campos obrigatórios não preenchidos. Verifique e tente novamente'),
        backgroundColor: cores.cor_accent,
      );
      ScaffoldMessenger.of(context).showSnackBar(snackBar);
    }
    else{
      controller_mobx.salvar_dados_iniciais(_controller_data.text, _controller_vistoriador.text, _controller_condutor.text, _controller_modelo.text, _controller_placa.text);
      Controller controller_novo = Controller();
      controller_mobx = controller_novo;
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => Main()
          )
      );
    }
  }
</code>```

For this question, I changed the lenght of the app, so it finishes on the first tab. On the last rows, we save the data, create a new instance of controller_mobx and then return to the main screen.

Where I'm creating a new Controller instance:

```<code>      Controller controller_novo = Controller();
      controller_mobx = controller_novo;
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => Main()
          )
      );
</code>```

So, after we finish and return to the Main Screen, the Controller must be without data. But when we start to answer the questions again, the fields are filled with the old answers. On the gif below I show the problem:
problem

Any help will be appreciate. Please, explain in details for best understanding.

How it should work:
what I need

What I needed to do to make it work:

```<code>[...]
@observable
bool vistoria_finalizada = false;
@action
alterar_vistoria_finalizada(bool valor){
  vistoria_finalizada = valor;
  if(valor){
    data = "";
    vistoriador = "";
    condutor = "";
    modelo_veiculo = "";
    placa = "";
  }
}
[...]
</code>```

Body:
I'm new developing with Flutter. I'm now using MobX to manage my app states and using Provider to pass the instance of my MobX Controller through screens.

The app is simple, where the user go through the screens answering the questions. Everytime a question is answered, the answer is saved on the MobX Controller. Everytime the user go to the next screen or return to the previous screen, if the field has an answer, the MobX Controller fill that answer. So, if the user return to the Main screen and start to answer the questions again, he will start where he stoped. All is working until the end of the questions.

When the user finish the answers, all the data is saved to Firebase and I need to "restart" the MobX Controller. But when I create a new instance of the MobX Controller and pass it to the older instance, the Provider insist in keep the old instance, with all the old answers.

I've tried a lot of things, and the only and incorrect way to make it works, was changing every variable of the class manually. And this is so sad, because is too much fields.

So, the question is: How can I create a new instance of my MobX Controller and make the Provider use this new instance?

Principal.dart: (the main screen of app)

void main() {
  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
  runApp(
      MultiProvider(
        providers: [
          Provider<Controller>(
            create: (BuildContext context) => Controller(),
          )
        ],
        child: MaterialApp(
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
              primaryColor: Colors.black
          ),
          home: Main(),
        ),
      )
  );
}

class Main extends StatefulWidget {
  const Main({Key? key}) : super(key: key);

  @override
  State createState() => _MainState();
}

class _MainState extends State {

  Controller controller_mobx = Controller();
  int _conexao = 0; // 0 - SEM CONEXAO | 1 - CONECTADO
  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
    controller_mobx = Provider.of(context);
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp
    ]);
  }

  @override
  Widget build(BuildContext context) {
    Util cores = Util();
    verificar_conexao();
    double altura_imagem =MediaQuery.of(context).size.height/5;
    controller_mobx.preenche_lista_vistoria();
    FlutterNativeSplash.remove();
    return Container(
      width: double.infinity,
      height: double.infinity,
      decoration: BoxDecoration(
          image: DecorationImage(
              image: AssetImage('images/wallpaper.png'),
              //colorFilter: ColorFilter.mode(Colors.white.withOpacity(0.75), BlendMode.modulate,),
              fit: BoxFit.cover
          )
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Padding(
            padding: EdgeInsets.all(16),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Container(
                  height: altura_imagem,
                  child: Image.asset("images/logo.png"),
                ),
                Padding(
                    padding: EdgeInsets.only(top: 16, bottom: 8),
                    child: Container(
                        height: 50,
                        width: double.infinity,
                        decoration: BoxDecoration(
                          color: Colors.transparent,
                          borderRadius: BorderRadius.all(Radius.circular(15)),
                          border: Border.all(
                              color: cores.laranja_teccel,
                              width: 2
                          ),
                        ),
                        child: Material(
                          borderRadius: BorderRadius.all(Radius.circular(15)),
                          child: InkWell(
                              splashColor: cores.laranja_teccel.withOpacity(0.25),
                              hoverColor: Colors.white,
                              borderRadius: BorderRadius.all(Radius.circular(12)),
                              onTap: (){
                                Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                        builder: (context) => NovaVistoria()
                                    )
                                );
                              },
                              child: Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: <Widget>[
                                  Padding(
                                    padding:EdgeInsets.only(left: 4),
                                    child: Icon(
                                      Icons.directions_car_rounded,
                                      color: cores.cor_app_bar,
                                      size: 30,
                                    ),
                                  ),
                                  Align(
                                    alignment: Alignment.center,
                                    child: Text(
                                      "Nova Vistoria",
                                      style: TextStyle(
                                        color: Colors.black,
                                        fontWeight: FontWeight.bold,
                                        fontSize: 14,
                                      ),
                                    ),
                                  ),
                                  Padding(
                                    padding:EdgeInsets.only(right: 4),
                                    child: Icon(
                                      Icons.directions_car_rounded,
                                      color: cores.cor_app_bar,
                                      size: 30,
                                    ),
                                  ),
                                ],
                              )
                          ),
                        )
                    )
                ),
              ],
            ),
          )
        ],
      ),
    );
  }

  verificar_conexao() async{
    Util verif = Util();
    _conexao = await  verif.verificar_conexao();
    if(_conexao == 0){
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => SemConexao()
          )
      );
    }
    else{
      return;
    }
  }
}

NovaVistoria.dart: (the screen used to manage each tab of questions on app)

class NovaVistoria extends StatefulWidget {
  @override
  State<NovaVistoria> createState() => _NovaVistoriaState();
}

class _NovaVistoriaState extends State<NovaVistoria> {
  Controller controller_mobx = Controller();

  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
    controller_mobx = Provider.of(context);
  }

  Util cores = Util();

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      decoration: BoxDecoration(
          image: DecorationImage(
              image: AssetImage('images/wallpaper.png'),
              //colorFilter: ColorFilter.mode(Colors.white.withOpacity(0.75), BlendMode.modulate,),
              fit: BoxFit.cover
          )
      ),
      child: Scaffold(
          backgroundColor: Colors.transparent,
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(50),
            child: AppBar(
              title: Text('Nova Vistoria', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white),),
              backgroundColor: cores.cor_app_bar,
              automaticallyImplyLeading: true,
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.vertical(
                  bottom: Radius.circular(10),
                ),
              ),
            ),
          ),
          body: Observer(
            builder: (_){
              return Padding(
                  padding: EdgeInsets.all(8),
                  child: controller_mobx.abas[controller_mobx.indice_tela]
              );
            },
          )
      ),
    );
  }
}

AbaDados.dart: (the first tab of questions)

class AbaDados extends StatefulWidget {
  const AbaDados({Key? key}) : super(key: key);

  @override
  State<AbaDados> createState() => _AbaDadosState();
}

class _AbaDadosState extends State<AbaDados> {

  Controller controller_mobx = Controller();

  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
    controller_mobx = Provider.of(context);
  }

  @override
  Widget build(BuildContext context) {
    DateTime now = DateTime.now();
    String data_relatorio = DateFormat('dd/MM/yyyy kk:mm:ss').format(now);
    if(controller_mobx.data.isEmpty)
      _controller_data.text = data_relatorio;
    else
      _controller_data.text = controller_mobx.data;
    _controller_vistoriador.text = controller_mobx.vistoriador;
    _controller_condutor.text = controller_mobx.condutor;
    _controller_modelo.text = controller_mobx.modelo_veiculo;
    _controller_placa.text = controller_mobx.placa;
    return Observer(
      builder: (_){
        return Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Padding(
              padding: EdgeInsets.only(bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                        child: Text(
                          "1 - Dados da Vistoria",
                          style: TextStyle(
                              color: cores.laranja_teccel,
                              fontSize: 24,
                              fontWeight: FontWeight.bold
                          ),
                        )
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          enabled: false,
                          controller: _controller_data,
                          keyboardType: TextInputType.name,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Data da Vistoria",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            disabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          onSubmitted: (content){

                          },
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          controller: _controller_vistoriador,
                          focusNode: _foco_vistoriador,
                          keyboardType: TextInputType.name,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Vistoriador",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          onSubmitted: (content){

                          },
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          controller: _controller_condutor,
                          focusNode: _foco_condutor,
                          keyboardType: TextInputType.name,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Condutor",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          onSubmitted: (content){

                          },
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          controller: _controller_modelo,
                          focusNode: _foco_modelo,
                          keyboardType: TextInputType.text,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.next,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Modelo do Veículo",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                          onSubmitted: (content){

                          },
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 8, bottom: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                        height: 50,
                        child: TextField(
                          controller: _controller_placa,
                          focusNode: _foco_placa,
                          keyboardType: TextInputType.text,
                          textCapitalization: TextCapitalization.characters,
                          textInputAction: TextInputAction.done,
                          cursorColor: cores.cor_app_bar,
                          style: TextStyle(
                              color: cores.cor_app_bar,
                              fontSize: 14,
                              fontWeight: FontWeight.bold
                          ),
                          decoration: InputDecoration(
                            floatingLabelBehavior: FloatingLabelBehavior.always,
                            counterText: "",
                            labelText: "Placa",
                            labelStyle: TextStyle(color: cores.laranja_teccel, fontWeight: FontWeight.normal),
                            fillColor: Colors.transparent,
                            hoverColor: cores.cor_app_bar,
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.cor_app_bar),
                              borderRadius: BorderRadius.circular(15),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(width: 2, color: cores.laranja_teccel),
                              borderRadius: BorderRadius.circular(15),
                            ),
                          ),
                        ),
                      ),
                    )
                  ]
              ),
            ),
            Expanded(child: Container()),
            Padding(
              padding: EdgeInsets.only(top: 8),
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Expanded(
                      child: Container(
                          height: 50,
                          width: double.infinity,
                          decoration: BoxDecoration(
                            color: Colors.transparent,
                            borderRadius: BorderRadius.all(Radius.circular(15)),
                            border: Border.all(
                                color: cores.laranja_teccel,
                                width: 2
                            ),
                          ),
                          child: Material(
                            borderRadius: BorderRadius.all(Radius.circular(15)),
                            child: InkWell(
                              splashColor: cores.laranja_teccel.withOpacity(0.25),
                              hoverColor: Colors.white,
                              borderRadius: BorderRadius.all(Radius.circular(12)),
                              onTap: (){
                                salvar_dados();
                              },
                              child: Align(
                                alignment: Alignment.center,
                                child: Text(
                                  "Avançar",
                                  style: TextStyle(
                                    color: Colors.black,
                                    fontWeight: FontWeight.bold,
                                    fontSize: 14,
                                  ),
                                ),
                              ),
                            ),
                          )
                      ),
                    )
                  ]
              ),
            ),
          ],
        );
      },
    );
  }
  salvar_dados(){
    if(_controller_vistoriador.text.isEmpty || _controller_condutor.text.isEmpty ||
        _controller_modelo.text.isEmpty || _controller_placa.text.isEmpty){
      final snackBar = SnackBar(
        content: const Text('Existem campos obrigatórios não preenchidos. Verifique e tente novamente'),
        backgroundColor: cores.cor_accent,
      );
      ScaffoldMessenger.of(context).showSnackBar(snackBar);
    }
    else{
      controller_mobx.salvar_dados_iniciais(_controller_data.text, _controller_vistoriador.text, _controller_condutor.text, _controller_modelo.text, _controller_placa.text);
      Controller controller_novo = Controller();
      controller_mobx = controller_novo;
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => Main()
          )
      );
    }
  }

For this question, I changed the lenght of the app, so it finishes on the first tab. On the last rows, we save the data, create a new instance of controller_mobx and then return to the main screen.

Where I'm creating a new Controller instance:

      Controller controller_novo = Controller();
      controller_mobx = controller_novo;
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => Main()
          )
      );

So, after we finish and return to the Main Screen, the Controller must be without data. But when we start to answer the questions again, the fields are filled with the old answers. On the gif below I show the problem:
problem

Any help will be appreciate. Please, explain in details for best understanding.

How it should work:
what I need

What I needed to do to make it work:

[...]
@observable
bool vistoria_finalizada = false;
@action
alterar_vistoria_finalizada(bool valor){
  vistoria_finalizada = valor;
  if(valor){
    data = "";
    vistoriador = "";
    condutor = "";
    modelo_veiculo = "";
    placa = "";
  }
}
[...]


来源: stackexchange

问:
SpringBoot3 + POI + Log4j GraalVm Native Image Runtime Error: Defining hidden classes at runtime is not supported
In the SpringBoot3 application built by Graalvm Native Image, I use Apache Poi to depend on log4j. The construction is successful, but the following errors occur at running. How can I configure it to avoid this error?

I tested in Spring Boot 2.7.1 + Spring Native, there is no problem.

```<code>  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.0)

2022-12-06T11:53:05.855+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.Application       : Starting AOT-processed Application using Java 17.0.5 with PID 18532 (D:\work-ide\IDEA\data-server\target\data-server.exe started by westinyang in D:\work-ide\IDEA\data-server\target)
2022-12-06T11:53:05.855+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.Application       : No active profile set, falling back to 1 default profile: "default"
2022-12-06T11:53:05.855+08:00  INFO 18532 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-12-06T11:53:05.855+08:00  INFO 18532 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-12-06T11:53:05.889+08:00  INFO 18532 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-12-06T11:53:05.889+08:00  INFO 18532 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-12-06T11:53:05.889+08:00  INFO 18532 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.1]
2022-12-06T11:53:05.897+08:00  INFO 18532 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-12-06T11:53:05.897+08:00  INFO 18532 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 41 ms
2022-12-06T11:53:05.920+08:00  INFO 18532 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-12-06T11:53:05.921+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.Application       : Started Application in 0.072 seconds (process running for 0.078)
ERROR StatusLogger Unable to load services for service class org.apache.logging.log4j.spi.Provider
 java.lang.InternalError: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
        at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:413)
        at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:315)
        at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:228)
        at java.base@17.0.5/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:341)
        at org.apache.logging.log4j.util.ServiceLoaderUtil.loadClassloaderServices(ServiceLoaderUtil.java:93)
        at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:74)
        at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:68)
        at org.apache.logging.log4j.util.ProviderUtil.<init>(ProviderUtil.java:67)
        at org.apache.logging.log4j.util.ProviderUtil.lazyInit(ProviderUtil.java:145)
        at org.apache.logging.log4j.util.ProviderUtil.hasProviders(ProviderUtil.java:129)
        at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:90)
        at org.apache.poi.util.IOUtils.<clinit>(IOUtils.java:43)
        at org.apache.poi.poifs.filesystem.FileMagic.valueOf(FileMagic.java:177)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:309)
        at cn.hutool.poi.excel.WorkbookUtil.createBook(WorkbookUtil.java:120)
        at cn.hutool.poi.excel.WorkbookUtil.createBook(WorkbookUtil.java:70)
        at cn.hutool.poi.excel.ExcelReader.<init>(ExcelReader.java:71)
        at cn.hutool.poi.excel.ExcelReader.<init>(ExcelReader.java:50)
        at cn.hutool.poi.excel.ExcelUtil.getReader(ExcelUtil.java:151)
        at cn.hutool.poi.excel.ExcelUtil.getReader(ExcelUtil.java:127)
        at com.example.dataserver.AppRunner.run(AppRunner.java:23)
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:758)
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:748)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
        at com.example.dataserver.Application.main(Application.java:13)
        at java.base@17.0.5/java.lang.reflect.Method.invoke(Method.java:568)
        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:178)
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)
        at java.base@17.0.5/java.lang.ClassLoader.defineClass0(ClassLoader.java:338)
        at java.base@17.0.5/java.lang.System$2.defineClass(System.java:2307)
        at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2439)
        at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClassAsLookup(MethodHandles.java:2420)
        at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup.defineHiddenClass(MethodHandles.java:2127)
        at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:407)
        ... 28 more
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
2022-12-06T11:53:05.981+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.AppRunner         : 3
2022-12-06T11:53:05.981+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.AppRunner         : Service running on 127.0.0.1:8080
</code>```

pom.xml dependencies

```<code><dependency>
    <groupId>cn.hutool</groupId>
    <artifactId>hutool-all</artifactId>
    <version>5.8.10</version>
</dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>5.2.3</version>
</dependency>
</code>```

I tried some solutions, but there is no effect yet，I joined the native-image parameter --initialize-at-run-time=org.apache.logging.log4j.spi.Provider

```<code><plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
    <buildArgs>
        <arg>--no-fallback</arg>
                <arg>--initialize-at-run-time=org.apache.logging.log4j.spi.Provider</arg>
                <arg>-H:+AddAllCharsets</arg>
    </buildArgs>
</configuration>
</plugin>
</code>```

ContentLicense: CC BY-SA 4.0

Body:
In the SpringBoot3 application built by Graalvm Native Image, I use Apache Poi to depend on log4j. The construction is successful, but the following errors occur at running. How can I configure it to avoid this error?

I tested in Spring Boot 2.7.1 + Spring Native, there is no problem.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.0)

2022-12-06T11:53:05.855+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.Application       : Starting AOT-processed Application using Java 17.0.5 with PID 18532 (D:\work-ide\IDEA\data-server\target\data-server.exe started by westinyang in D:\work-ide\IDEA\data-server\target)
2022-12-06T11:53:05.855+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.Application       : No active profile set, falling back to 1 default profile: "default"
2022-12-06T11:53:05.855+08:00  INFO 18532 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-12-06T11:53:05.855+08:00  INFO 18532 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-12-06T11:53:05.889+08:00  INFO 18532 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-12-06T11:53:05.889+08:00  INFO 18532 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-12-06T11:53:05.889+08:00  INFO 18532 --- [  restartedMain] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.1]
2022-12-06T11:53:05.897+08:00  INFO 18532 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-12-06T11:53:05.897+08:00  INFO 18532 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 41 ms
2022-12-06T11:53:05.920+08:00  INFO 18532 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-12-06T11:53:05.921+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.Application       : Started Application in 0.072 seconds (process running for 0.078)
ERROR StatusLogger Unable to load services for service class org.apache.logging.log4j.spi.Provider
 java.lang.InternalError: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
        at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:413)
        at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:315)
        at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:228)
        at java.base@17.0.5/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:341)
        at org.apache.logging.log4j.util.ServiceLoaderUtil.loadClassloaderServices(ServiceLoaderUtil.java:93)
        at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:74)
        at org.apache.logging.log4j.util.ServiceLoaderUtil.loadServices(ServiceLoaderUtil.java:68)
        at org.apache.logging.log4j.util.ProviderUtil.<init>(ProviderUtil.java:67)
        at org.apache.logging.log4j.util.ProviderUtil.lazyInit(ProviderUtil.java:145)
        at org.apache.logging.log4j.util.ProviderUtil.hasProviders(ProviderUtil.java:129)
        at org.apache.logging.log4j.LogManager.<clinit>(LogManager.java:90)
        at org.apache.poi.util.IOUtils.<clinit>(IOUtils.java:43)
        at org.apache.poi.poifs.filesystem.FileMagic.valueOf(FileMagic.java:177)
        at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:309)
        at cn.hutool.poi.excel.WorkbookUtil.createBook(WorkbookUtil.java:120)
        at cn.hutool.poi.excel.WorkbookUtil.createBook(WorkbookUtil.java:70)
        at cn.hutool.poi.excel.ExcelReader.<init>(ExcelReader.java:71)
        at cn.hutool.poi.excel.ExcelReader.<init>(ExcelReader.java:50)
        at cn.hutool.poi.excel.ExcelUtil.getReader(ExcelUtil.java:151)
        at cn.hutool.poi.excel.ExcelUtil.getReader(ExcelUtil.java:127)
        at com.example.dataserver.AppRunner.run(AppRunner.java:23)
        at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:758)
        at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:748)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
        at com.example.dataserver.Application.main(Application.java:13)
        at java.base@17.0.5/java.lang.reflect.Method.invoke(Method.java:568)
        at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:775)
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.windows.WindowsPlatformThreads.osThreadStartRoutine(WindowsPlatformThreads.java:178)
Caused by: com.oracle.svm.core.jdk.UnsupportedFeatureError: Defining hidden classes at runtime is not supported.
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89)
        at java.base@17.0.5/java.lang.ClassLoader.defineClass0(ClassLoader.java:338)
        at java.base@17.0.5/java.lang.System$2.defineClass(System.java:2307)
        at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(MethodHandles.java:2439)
        at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClassAsLookup(MethodHandles.java:2420)
        at java.base@17.0.5/java.lang.invoke.MethodHandles$Lookup.defineHiddenClass(MethodHandles.java:2127)
        at java.base@17.0.5/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:407)
        ... 28 more
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
2022-12-06T11:53:05.981+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.AppRunner         : 3
2022-12-06T11:53:05.981+08:00  INFO 18532 --- [  restartedMain] com.example.dataserver.AppRunner         : Service running on 127.0.0.1:8080

pom.xml dependencies

<dependency>
    <groupId>cn.hutool</groupId>
    <artifactId>hutool-all</artifactId>
    <version>5.8.10</version>
</dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>5.2.3</version>
</dependency>

I tried some solutions, but there is no effect yet，I joined the native-image parameter --initialize-at-run-time=org.apache.logging.log4j.spi.Provider

<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
    <buildArgs>
        <arg>--no-fallback</arg>
                <arg>--initialize-at-run-time=org.apache.logging.log4j.spi.Provider</arg>
                <arg>-H:+AddAllCharsets</arg>
    </buildArgs>
</configuration>
</plugin>


问:
Extracting the labels attribute from columns of a .dta file in R
I am trying to extract labels attribute from a number of columns from a stata .dta file into a dataframe.

However the attributes(data$datattr) function returns NULL value for some reason. Could you help out with this ?

```<code>    data <- read_dta('C:\\Users\\...)
    colnames1 <- data.frame(colnames(data))
    colnames1$var_descr = NA

    for (i in 1:nrow(colnames1)){
      dataattr <- colnames1[i,1]
      list_of_attributes <- attributes(data$datattr)
      colnames1[i,2] <- list_of_attributes[[1]]
     }
</code>```

I am expecting this loop to populate the empty column of colnames1 dataframe. A better solution for getting the variables and labels in one place would also interest me, I am new to coding.

Thanks in advance!

Body:
I am trying to extract labels attribute from a number of columns from a stata .dta file into a dataframe.

However the attributes(data$datattr) function returns NULL value for some reason. Could you help out with this ?

    data <- read_dta('C:\\Users\\...)
    colnames1 <- data.frame(colnames(data))
    colnames1$var_descr = NA

    for (i in 1:nrow(colnames1)){
      dataattr <- colnames1[i,1]
      list_of_attributes <- attributes(data$datattr)
      colnames1[i,2] <- list_of_attributes[[1]]
     }

I am expecting this loop to populate the empty column of colnames1 dataframe. A better solution for getting the variables and labels in one place would also interest me, I am new to coding.

Thanks in advance!


问:
API Key not found Google Maps React Native - PC
I am using React Native Visual Studio Code - PC having issues with the API. I know I have it setup for billing so the API should work on that end. Any ideas how to resolve this? I have tried to follow all the steps to set it up but nothing seems to resolve it. I have looked at the documentation and I believe I have done all the steps. Picture of full error below.

AndroidManifest.xml file:

```<code><manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.tool_right">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

        <!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
        <meta-data
                android:name="com.google.android.geo.API_KEY"
                android:value="My API Key is here just not displayed here for security reasons"/>

        <!-- You will also only need to add this uses-library tag -->
        <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    </application>

</manifest>
</code>```

build.gradle:

```<code>apply plugin: "com.android.application"

import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        playServicesVersion = "17.0.0"

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.2.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:5.0.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
</code>```

enter image description here

Body:
I am using React Native Visual Studio Code - PC having issues with the API. I know I have it setup for billing so the API should work on that end. Any ideas how to resolve this? I have tried to follow all the steps to set it up but nothing seems to resolve it. I have looked at the documentation and I believe I have done all the steps. Picture of full error below.

AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.tool_right">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:allowBackup="false"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:launchMode="singleTask"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

        <meta-data
                android:name="com.google.android.geo.API_KEY"
                android:value="My API Key is here just not displayed here for security reasons"/>

        <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    </application>

</manifest>

build.gradle:

apply plugin: "com.android.application"

import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        playServicesVersion = "17.0.0"

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.2.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:5.0.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

enter image description here


问:
Problems trying to work around WebSecurityConfigurerAdapter deprecation using Spring Boot 2.7.5
When updating spring boot version 2.7.5 I noticed that the WebSecurityConfigurerAdapter class was deprecated in this version.
I followed the steps as described in section 2.2 on article on Baeldung
to customize my application's authentication rules, but the filterChain method is not even being called during application startup, as with the "configure" function using spring boot version 2.2.3.
Can anyone help me?

Below I show the before and after of my changes.

Before

```<code>@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration : WebSecurityConfigurerAdapter() {

    override fun configure(http: HttpSecurity) {
        val tokenTypes: List<TokenType> = mapper.readValue(jsonTokenTypes, Array<TokenType>::class.java).toList()
        http.csrf().disable()
            .authorizeRequests()
            .antMatchers("/graphql").permitAll()
            .and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .addFilterBefore(
                AuthFilter.create(keySet, tokenTypes),
                RequestHeaderAuthenticationFilter::class.java
            )
    }
}
</code>```

After

```<code>@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration() {

    @Value("\${vehicle.op.jwk.key-set}")
    private lateinit var keySet: List<String>

    @Value("\${vehicle.op.jwt.token-types}")
    private lateinit var jsonTokenTypes: String

    protected val mapper = jacksonObjectMapper()

    @Bean
    fun filterChain(http: HttpSecurity): SecurityFilterChain {
        val tokenTypes: List<TokenType> = mapper.readValue(jsonTokenTypes, Array<TokenType>::class.java).toList()
        http.csrf().disable()
            .authorizeRequests()
            .antMatchers("/graphql").permitAll()
            .and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .addFilterBefore(
                AuthFilter.create(keySet, tokenTypes),
                RequestHeaderAuthenticationFilter::class.java
            )

        return http.build()

    }
</code>```

Application starts up normally, as shown in the log below:

```<code>13:22:33: Executing 'bootRun -Dspring.profiles.active=homolog'...

> Task :checkApolloVersions UP-TO-DATE
> Task :generateMainServiceApolloSources NO-SOURCE
> Task :compileKotlin UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootRunMainClassName UP-TO-DATE

> Task :bootRun   __  __       _     _ ___________  |  \/  | ___ | |__ (_)___  \ \ \ \  | |\/| |/ _ \| '_ \| |  / / \ \ \ \  | |  | | (_) | |_) | | / /   ) ) ) )  |_|  |_|\___/|_.__/|_|/_/   / / / /
===========================/_/_/_/  :: my_application :: (vlatest)

2022-12-06 13:22:37.312  INFO 29076 --- [           main] i.company.op.vehicle.VehicleApplicationKt  : Starting VehicleApplicationKt using Java 11.0.16 on DESKTOP-07SSK0A with PID 29076 (C:\company\GitHub\my_application\build\classes\kotlin\main started by admin in C:\company\GitHub\my_application) 2022-12-06 13:22:37.316  INFO 29076 --- [           main] i.company.op.vehicle.VehicleApplicationKt  : No active profile set, falling back to 1 default profile: "default" 2022-12-06 13:22:37.816  INFO 29076 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2022-12-06 13:22:37.883  INFO 29076
--- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 62 ms. Found 4 JPA repository interfaces. 2022-12-06 13:22:38.065  INFO 29076 --- [       main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=c811da27-aff3-39ab-b4ee-d6bb20987e72 2022-12-06 13:22:38.602  INFO 29076 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9090 (http) 2022-12-06 13:22:38.611  INFO 29076 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat] 2022-12-06 13:22:38.612  INFO 29076 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.68] 2022-12-06 13:22:38.718  INFO 29076 --- [       main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext 2022-12-06 13:22:38.719  INFO 29076 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1351 ms 2022-12-06 13:22:38.872  INFO 29076 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting... 2022-12-06 13:22:39.037  INFO 29076 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed. 2022-12-06 13:22:39.507  INFO 29076 --- [           main] liquibase.executor.jvm.JdbcExecutor      : SELECT COUNT(*) FROM public.liq_db_changelog_lock 2022-12-06 13:22:39.519  INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor      : SELECT COUNT(*) FROM public.liq_db_changelog_lock 2022-12-06 13:22:39.520  INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor      : SELECT LOCKED FROM public.liq_db_changelog_lock WHERE ID=1 2022-12-06 13:22:39.533  INFO 29076 --- [           main] l.lockservice.StandardLockService        : Successfully acquired change log lock 2022-12-06 13:22:39.545  INFO 29076 --- [           main] liquibase.changelog.DatabaseChangeLog    : Reading resource: db/changelog/202210050955-changelog.sql 2022-12-06 13:22:39.552  INFO 29076 --- [           main] liquibase.changelog.DatabaseChangeLog    : Reading resource: db/changelog/202210051005-changelog.sql 2022-12-06 13:22:39.561  INFO 29076 --- [           main] liquibase.changelog.DatabaseChangeLog    : Reading resource: db/changelog/202210141724-changelog.sql 2022-12-06 13:22:39.569  INFO 29076 --- [           main] liquibase.changelog.DatabaseChangeLog    : Reading resource: db/changelog/202210310837-changelog.sql 2022-12-06 13:22:39.653  INFO 29076 --- [           main] liquibase.executor.jvm.JdbcExecutor      : SELECT MD5SUM FROM public.liq_db_changelog WHERE MD5SUM IS NOT NULL LIMIT 1 2022-12-06 13:22:39.657  INFO 29076 --- [           main] liquibase.executor.jvm.JdbcExecutor      : SELECT COUNT(*) FROM public.liq_db_changelog 2022-12-06 13:22:39.659  INFO 29076 --- [      main] l.c.StandardChangeLogHistoryService      : Reading from public.liq_db_changelog 2022-12-06 13:22:39.659  INFO 29076 --- [      main] liquibase.executor.jvm.JdbcExecutor      : SELECT * FROM public.liq_db_changelog ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC 2022-12-06 13:22:39.683  INFO 29076 --- [           main] l.lockservice.StandardLockService        : Successfully released change log lock 2022-12-06 13:22:39.831  INFO 29076 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default] 2022-12-06 13:22:39.911  INFO 29076 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.12.Final 2022-12-06 13:22:40.122  INFO 29076 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2022-12-06 13:22:40.242  INFO 29076
--- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect 2022-12-06 13:22:40.651  INFO 29076 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2022-12-06 13:22:40.658  INFO 29076 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2022-12-06 13:22:42.695  INFO 29076 --- [           main] s.b.a.g.s.GraphQlWebMvcAutoConfiguration : GraphQL endpoint HTTP POST /graphql 2022-12-06 13:22:43.217  WARN 29076 --- [           main] .s.s.UserDetailsServiceAutoConfiguration :

Using generated security password: 6e231318-c400-4c42-bb52-079a429bd04a

This generated password is for development use only. Your security configuration must be updated before running your application in production.

2022-12-06 13:22:43.411  INFO 29076 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4e92c6c2, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@71a18feb, org.springframework.security.web.context.SecurityContextPersistenceFilter@26aecf31, org.springframework.security.web.header.HeaderWriterFilter@693f9ab5, org.springframework.security.web.csrf.CsrfFilter@197d6cc9, org.springframework.security.web.authentication.logout.LogoutFilter@286f8e90, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@327fd5c9, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@3d1b6816, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@66032b8d, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@70a9f4b7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1abacff3, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4a3d4cd2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@7c1a5092, org.springframework.security.web.session.SessionManagementFilter@3f04847e, org.springframework.security.web.access.ExceptionTranslationFilter@76e56b17, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@169f4152] 2022-12-06 13:22:43.478  INFO 29076 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9090 (http) with context path '' 2022-12-06 13:22:43.488  INFO 29076
--- [           main] i.company.op.vehicle.VehicleApplicationKt  : Started VehicleApplicationKt in 6.557 seconds (JVM running for 6.906)
</code>```

Originally my application validates only the Bearer Token given in the request header, and after upgrade spring boot version now it requires a user/password authentication.

Body:
When updating spring boot version 2.7.5 I noticed that the WebSecurityConfigurerAdapter class was deprecated in this version.
I followed the steps as described in section 2.2 on article on Baeldung
to customize my application's authentication rules, but the filterChain method is not even being called during application startup, as with the "configure" function using spring boot version 2.2.3.
Can anyone help me?

Below I show the before and after of my changes.

Before

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration : WebSecurityConfigurerAdapter() {

    override fun configure(http: HttpSecurity) {
        val tokenTypes: List<TokenType> = mapper.readValue(jsonTokenTypes, Array<TokenType>::class.java).toList()
        http.csrf().disable()
            .authorizeRequests()
            .antMatchers("/graphql").permitAll()
            .and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .addFilterBefore(
                AuthFilter.create(keySet, tokenTypes),
                RequestHeaderAuthenticationFilter::class.java
            )
    }
}

After

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
class SecurityConfiguration() {

    @Value("\${vehicle.op.jwk.key-set}")
    private lateinit var keySet: List<String>

    @Value("\${vehicle.op.jwt.token-types}")
    private lateinit var jsonTokenTypes: String

    protected val mapper = jacksonObjectMapper()

    @Bean
    fun filterChain(http: HttpSecurity): SecurityFilterChain {
        val tokenTypes: List<TokenType> = mapper.readValue(jsonTokenTypes, Array<TokenType>::class.java).toList()
        http.csrf().disable()
            .authorizeRequests()
            .antMatchers("/graphql").permitAll()
            .and()
            .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
            .addFilterBefore(
                AuthFilter.create(keySet, tokenTypes),
                RequestHeaderAuthenticationFilter::class.java
            )

        return http.build()

    }

Application starts up normally, as shown in the log below:

13:22:33: Executing 'bootRun -Dspring.profiles.active=homolog'...

> Task :checkApolloVersions UP-TO-DATE
> Task :generateMainServiceApolloSources NO-SOURCE
> Task :compileKotlin UP-TO-DATE
> Task :compileJava NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootRunMainClassName UP-TO-DATE

> Task :bootRun   __  __       _     _ ___________  |  \/  | ___ | |__ (_)___  \ \ \ \  | |\/| |/ _ \| '_ \| |  / / \ \ \ \  | |  | | (_) | |_) | | / /   ) ) ) )  |_|  |_|\___/|_.__/|_|/_/   / / / /
===========================/_/_/_/  :: my_application :: (vlatest)

2022-12-06 13:22:37.312  INFO 29076 --- [           main] i.company.op.vehicle.VehicleApplicationKt  : Starting VehicleApplicationKt using Java 11.0.16 on DESKTOP-07SSK0A with PID 29076 (C:\company\GitHub\my_application\build\classes\kotlin\main started by admin in C:\company\GitHub\my_application) 2022-12-06 13:22:37.316  INFO 29076 --- [           main] i.company.op.vehicle.VehicleApplicationKt  : No active profile set, falling back to 1 default profile: "default" 2022-12-06 13:22:37.816  INFO 29076 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2022-12-06 13:22:37.883  INFO 29076
--- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 62 ms. Found 4 JPA repository interfaces. 2022-12-06 13:22:38.065  INFO 29076 --- [       main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=c811da27-aff3-39ab-b4ee-d6bb20987e72 2022-12-06 13:22:38.602  INFO 29076 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9090 (http) 2022-12-06 13:22:38.611  INFO 29076 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat] 2022-12-06 13:22:38.612  INFO 29076 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.68] 2022-12-06 13:22:38.718  INFO 29076 --- [       main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext 2022-12-06 13:22:38.719  INFO 29076 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1351 ms 2022-12-06 13:22:38.872  INFO 29076 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting... 2022-12-06 13:22:39.037  INFO 29076 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed. 2022-12-06 13:22:39.507  INFO 29076 --- [           main] liquibase.executor.jvm.JdbcExecutor      : SELECT COUNT(*) FROM public.liq_db_changelog_lock 2022-12-06 13:22:39.519  INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor      : SELECT COUNT(*) FROM public.liq_db_changelog_lock 2022-12-06 13:22:39.520  INFO 29076 --- [ main] liquibase.executor.jvm.JdbcExecutor      : SELECT LOCKED FROM public.liq_db_changelog_lock WHERE ID=1 2022-12-06 13:22:39.533  INFO 29076 --- [           main] l.lockservice.StandardLockService        : Successfully acquired change log lock 2022-12-06 13:22:39.545  INFO 29076 --- [           main] liquibase.changelog.DatabaseChangeLog    : Reading resource: db/changelog/202210050955-changelog.sql 2022-12-06 13:22:39.552  INFO 29076 --- [           main] liquibase.changelog.DatabaseChangeLog    : Reading resource: db/changelog/202210051005-changelog.sql 2022-12-06 13:22:39.561  INFO 29076 --- [           main] liquibase.changelog.DatabaseChangeLog    : Reading resource: db/changelog/202210141724-changelog.sql 2022-12-06 13:22:39.569  INFO 29076 --- [           main] liquibase.changelog.DatabaseChangeLog    : Reading resource: db/changelog/202210310837-changelog.sql 2022-12-06 13:22:39.653  INFO 29076 --- [           main] liquibase.executor.jvm.JdbcExecutor      : SELECT MD5SUM FROM public.liq_db_changelog WHERE MD5SUM IS NOT NULL LIMIT 1 2022-12-06 13:22:39.657  INFO 29076 --- [           main] liquibase.executor.jvm.JdbcExecutor      : SELECT COUNT(*) FROM public.liq_db_changelog 2022-12-06 13:22:39.659  INFO 29076 --- [      main] l.c.StandardChangeLogHistoryService      : Reading from public.liq_db_changelog 2022-12-06 13:22:39.659  INFO 29076 --- [      main] liquibase.executor.jvm.JdbcExecutor      : SELECT * FROM public.liq_db_changelog ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC 2022-12-06 13:22:39.683  INFO 29076 --- [           main] l.lockservice.StandardLockService        : Successfully released change log lock 2022-12-06 13:22:39.831  INFO 29076 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default] 2022-12-06 13:22:39.911  INFO 29076 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.12.Final 2022-12-06 13:22:40.122  INFO 29076 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2022-12-06 13:22:40.242  INFO 29076
--- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL9Dialect 2022-12-06 13:22:40.651  INFO 29076 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2022-12-06 13:22:40.658  INFO 29076 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2022-12-06 13:22:42.695  INFO 29076 --- [           main] s.b.a.g.s.GraphQlWebMvcAutoConfiguration : GraphQL endpoint HTTP POST /graphql 2022-12-06 13:22:43.217  WARN 29076 --- [           main] .s.s.UserDetailsServiceAutoConfiguration :

Using generated security password: 6e231318-c400-4c42-bb52-079a429bd04a

This generated password is for development use only. Your security configuration must be updated before running your application in production.

2022-12-06 13:22:43.411  INFO 29076 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4e92c6c2, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@71a18feb, org.springframework.security.web.context.SecurityContextPersistenceFilter@26aecf31, org.springframework.security.web.header.HeaderWriterFilter@693f9ab5, org.springframework.security.web.csrf.CsrfFilter@197d6cc9, org.springframework.security.web.authentication.logout.LogoutFilter@286f8e90, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@327fd5c9, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@3d1b6816, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@66032b8d, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@70a9f4b7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1abacff3, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4a3d4cd2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@7c1a5092, org.springframework.security.web.session.SessionManagementFilter@3f04847e, org.springframework.security.web.access.ExceptionTranslationFilter@76e56b17, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@169f4152] 2022-12-06 13:22:43.478  INFO 29076 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9090 (http) with context path '' 2022-12-06 13:22:43.488  INFO 29076
--- [           main] i.company.op.vehicle.VehicleApplicationKt  : Started VehicleApplicationKt in 6.557 seconds (JVM running for 6.906)

Originally my application validates only the Bearer Token given in the request header, and after upgrade spring boot version now it requires a user/password authentication.


问:
XLSM files get converted to XLSX file when downloading using pre-signed S3 url
We are downloading XLSM file from S3 but it getting converted into XLSX file . we are using aws sdkenter link description here


问:
The effect of the registry path in the pnpm-lock.yaml
I find that dependencies are prefixed with registry path like blew:

packages:

  registry.npmmirror.com/@ampproject/remapping/2.2.0:
    resolution: {integrity: sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@ampproject/remapping/-/remapping-2.2.0.tgz}
    name: '@ampproject/remapping'
    version: 2.2.0
    engines: {node: '>=6.0.0'}
    dependencies:
      '@jridgewell/gen-mapping': registry.npmmirror.com/@jridgewell/gen-mapping/0.1.1
      '@jridgewell/trace-mapping': registry.npmmirror.com/@jridgewell/trace-mapping/0.3.15
    dev: true
```
<p>does it means that the project will install packages with the registry?</p>
<p>but i find there is no registry path in another project's lock file</p>
<pre class="lang-yaml prettyprint-override"><code>packages:

  /@ampproject/remapping/2.2.0:
    resolution: {integrity: sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==}
    engines: {node: '>=6.0.0'}
    dependencies:
      '@jridgewell/gen-mapping': 0.1.1
      '@jridgewell/trace-mapping': 0.3.17
    dev: true
</code>```

how did that come about?
please help

Body:
I find that dependencies are prefixed with registry path like blew:

packages:

  registry.npmmirror.com/@ampproject/remapping/2.2.0:
    resolution: {integrity: sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@ampproject/remapping/-/remapping-2.2.0.tgz}
    name: '@ampproject/remapping'
    version: 2.2.0
    engines: {node: '>=6.0.0'}
    dependencies:
      '@jridgewell/gen-mapping': registry.npmmirror.com/@jridgewell/gen-mapping/0.1.1
      '@jridgewell/trace-mapping': registry.npmmirror.com/@jridgewell/trace-mapping/0.3.15
    dev: true

does it means that the project will install packages with the registry?

but i find there is no registry path in another project's lock file

packages:

  /@ampproject/remapping/2.2.0:
    resolution: {integrity: sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==}
    engines: {node: '>=6.0.0'}
    dependencies:
      '@jridgewell/gen-mapping': 0.1.1
      '@jridgewell/trace-mapping': 0.3.17
    dev: true

how did that come about?
please help


问:
How to build a radar chart with a polygonal grid using victory-native package?
I want to build a radar chart like this link using victory-native package on react-native. The example I have on the official site is this one: link. As you can see, the grid is rounded and I need I polygonal grid. How can I achieve that using victory-native package?</p>